Files
YAEP/composeApp/src/commonMain/kotlin/domain/Game.kt
2024-06-11 23:41:39 +02:00

23 lines
672 B
Kotlin

package domain
const val PUZZLE_SIZE = 6
class Game(
val categories: List<ItemCategory>,
val grid: Grid,
val horizontalRules: List<HorizontalRule>,
val verticalRules: List<VerticalRule>
) {
fun areCategoriesValid(): Boolean = categories.mapIndexed { index, category ->
category.any { item ->
categories.filterIndexed { i, _ -> i > index }.any { it.contains(item) }
}
}.none { it }
fun areRulesViolated(): Boolean = horizontalRules
.map { it.isRuleViolated(grid) }
.reduce { a, b -> a || b }
|| verticalRules
.map { it.isRuleViolated(grid) }
.reduce { a, b -> a || b }
}