Fix some inspection issues
This commit is contained in:
@@ -6,9 +6,10 @@ class Game(
|
||||
val grid: Grid,
|
||||
val clues: Collection<Clue>
|
||||
) {
|
||||
val log = KotlinLogging.logger { }
|
||||
val horizontalClues = clues.filterIsInstance<HorizontalClue>()
|
||||
val verticalClues = clues.filterIsInstance<SameColumnClue<ItemClass<*>, ItemClass<*>>>()
|
||||
private val log = KotlinLogging.logger { }
|
||||
val horizontalClues: List<HorizontalClue> = clues.filterIsInstance<HorizontalClue>()
|
||||
val verticalClues: List<SameColumnClue<ItemClass<*>, ItemClass<*>>> =
|
||||
clues.filterIsInstance<SameColumnClue<ItemClass<*>, ItemClass<*>>>()
|
||||
|
||||
private val onStartListeners = mutableListOf<() -> Unit>()
|
||||
private val onSolvedListeners = mutableListOf<() -> Unit>()
|
||||
|
||||
@@ -44,9 +44,6 @@ fun <C : ItemClass<C>> GameCell<C>?.mayBe(item: Item<C>, mayHaveSelection: Boole
|
||||
this != null &&
|
||||
((mayHaveSelection && selection == item) || (selection == null && options.contains(item)))
|
||||
|
||||
fun <C : ItemClass<C>> GameCell<C>?.isA(item: Item<C>): Boolean =
|
||||
this != null && selection == item
|
||||
|
||||
fun <C : ItemClass<C>> GameCell<C>?.hasNoSelection(): Boolean =
|
||||
this != null && this.selection == null
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class GameRow<C : ItemClass<C>>(
|
||||
val category: ItemClassCompanion<C>,
|
||||
val options: List<Item<C>>,
|
||||
@@ -79,4 +80,5 @@ class GameRow<C : ItemClass<C>>(
|
||||
}
|
||||
return didChange
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@Suppress("UNCHECKED_CAST", "JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class Grid(
|
||||
val rows: List<GameRow<*>>
|
||||
) : List<GameRow<ItemClass<*>>> by rows as List<GameRow<ItemClass<*>>> {
|
||||
@@ -41,7 +41,7 @@ class Grid(
|
||||
}
|
||||
}
|
||||
|
||||
fun List<List<Item<ItemClass<*>>>>.toGrid() = Grid(
|
||||
fun List<List<Item<ItemClass<*>>>>.toGrid(): Grid = Grid(
|
||||
map { row ->
|
||||
GameRow(
|
||||
category = row.first().itemType.companion,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class ObservableSet<E> private constructor(
|
||||
private val mutableSet: MutableSet<E>,
|
||||
private val onElementChanged: (before: Set<E>, after: Set<E>) -> Unit
|
||||
|
||||
@@ -85,7 +85,7 @@ class NeighbourClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b: I
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString() = "$aType is next to $bType"
|
||||
override fun toString(): String = "$aType is next to $bType"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
@@ -147,7 +147,7 @@ class OrderClue<L : ItemClass<L>, R : ItemClass<R>>(val left: Item<L>, val right
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString() = "$leftType is left of $rightType"
|
||||
override fun toString(): String = "$leftType is left of $rightType"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
@@ -377,7 +377,7 @@ class SameColumnClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b:
|
||||
}
|
||||
|
||||
class PositionClue<C : ItemClass<C>>(val item: Item<C>, val index: Int) : Clue() {
|
||||
val itemType = item.itemType
|
||||
val itemType: C = item.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val i = grid.indexOf(item.itemType)
|
||||
@@ -401,7 +401,7 @@ class PositionClue<C : ItemClass<C>>(val item: Item<C>, val index: Int) : Clue()
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString() = "$itemType is at position $index"
|
||||
override fun toString(): String = "$itemType is at position $index"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
|
||||
@@ -11,7 +11,7 @@ enum class Animal(symbol: String) : ItemClass<Animal> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Animal.Companion
|
||||
get() = Animal
|
||||
|
||||
companion object : ItemClassCompanion<Animal> {
|
||||
@@ -31,7 +31,7 @@ enum class Nationality(symbol: String) : ItemClass<Nationality> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Nationality.Companion
|
||||
get() = Nationality
|
||||
|
||||
companion object : ItemClassCompanion<Nationality> {
|
||||
@@ -50,7 +50,7 @@ enum class Drink(symbol: String) : ItemClass<Drink> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Drink.Companion
|
||||
get() = Drink
|
||||
|
||||
companion object : ItemClassCompanion<Drink> {
|
||||
@@ -70,7 +70,7 @@ enum class Profession(symbol: String) : ItemClass<Profession> {
|
||||
|
||||
override val symbols: Array<String> = idic(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Profession.Companion
|
||||
get() = Profession
|
||||
|
||||
companion object : ItemClassCompanion<Profession> {
|
||||
@@ -92,7 +92,7 @@ enum class Fruit(symbol: String) : ItemClass<Fruit> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Fruit.Companion
|
||||
get() = Fruit
|
||||
|
||||
companion object : ItemClassCompanion<Fruit> {
|
||||
@@ -113,7 +113,7 @@ enum class Dessert(symbol: String) : ItemClass<Dessert> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Dessert.Companion
|
||||
get() = Dessert
|
||||
|
||||
companion object : ItemClassCompanion<Dessert> {
|
||||
@@ -132,7 +132,7 @@ enum class Transportation(symbol: String) : ItemClass<Transportation> {
|
||||
|
||||
override val symbols: Array<String> = arrayOf(symbol)
|
||||
|
||||
override val companion
|
||||
override val companion: Transportation.Companion
|
||||
get() = Transportation
|
||||
|
||||
companion object : ItemClassCompanion<Transportation> {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
abstract class ClueTest {
|
||||
protected val size = 6
|
||||
protected val size: Int = 6
|
||||
|
||||
protected fun createGrid(
|
||||
selection: (Item<ItemClass<*>>) -> Item<ItemClass<*>>? = { it }
|
||||
) = Grid(
|
||||
): Grid = Grid(
|
||||
ItemClass.randomClasses(size)
|
||||
.map {
|
||||
it.randomItems(size).map { item -> Item(item) }
|
||||
|
||||
Reference in New Issue
Block a user