Fix some inspection issues
This commit is contained in:
@@ -18,7 +18,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import ch.dissem.yaep.ui.common.App
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
@@ -34,7 +33,7 @@ class MainActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
var game by remember { mutableStateOf<Game>(generateGame()) }
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
|
||||
Scaffold(
|
||||
|
||||
@@ -4,7 +4,7 @@ import ch.dissem.yaep.domain.Game
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
val log = KotlinLogging.logger {}
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
actual fun CoroutineScope.logGame(game: Game) {
|
||||
log.debug { "Game: $game" }
|
||||
|
||||
@@ -180,17 +180,17 @@ fun PuzzleGrid(
|
||||
item.options.add(it)
|
||||
},
|
||||
selectedItem = selection,
|
||||
onSelectItem = {
|
||||
if (it != null) {
|
||||
onSelectItem = { selectedItem ->
|
||||
if (selectedItem != null) {
|
||||
grid.snapshot()
|
||||
item.selection = it
|
||||
item.selection = selectedItem
|
||||
row.cleanupOptions()
|
||||
} else {
|
||||
while (item.selection != null) {
|
||||
if (!grid.undo()) break
|
||||
}
|
||||
options.forEach {
|
||||
it.enabled = item.options.contains(it.item)
|
||||
options.forEach { option ->
|
||||
option.enabled = item.options.contains(option.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ private enum class AspectRatio {
|
||||
PORTRAIT, LANDSCAPE, SQUARISH;
|
||||
|
||||
companion object {
|
||||
private const val landscapeRatio = 1.4f
|
||||
private const val portraitRatio = 1 / landscapeRatio
|
||||
private const val ASPECT_RATIO_LANDSCAPE = 1.4f
|
||||
private const val ASPECT_RATIO_PORTRAIT = 1 / ASPECT_RATIO_LANDSCAPE
|
||||
|
||||
fun from(constraints: Constraints): AspectRatio {
|
||||
val ratio = constraints.maxWidth.toFloat() / constraints.maxHeight.toFloat()
|
||||
return when {
|
||||
ratio < portraitRatio -> PORTRAIT
|
||||
ratio > landscapeRatio -> LANDSCAPE
|
||||
ratio < ASPECT_RATIO_PORTRAIT -> PORTRAIT
|
||||
ratio > ASPECT_RATIO_LANDSCAPE -> LANDSCAPE
|
||||
else -> SQUARISH
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlin.io.path.writeText
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
val log = KotlinLogging.logger {}
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
actual fun CoroutineScope.logGame(game: Game) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.WindowPlacement
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import ch.dissem.yaep.ui.common.App
|
||||
import ch.dissem.yaep.ui.common.theme.emojiFontFamily
|
||||
@@ -39,7 +38,7 @@ fun main(): Unit = application {
|
||||
placement = WindowPlacement.Floating,
|
||||
size = DpSize(1250.dp, 800.dp)
|
||||
)
|
||||
var game by remember { mutableStateOf<Game>(generateGame()) }
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
|
||||
@@ -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) }
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
Reference in New Issue
Block a user