Add and improve domain (WIP)
This commit is contained in:
21
composeApp/src/commonMain/kotlin/domain/Game.kt
Normal file
21
composeApp/src/commonMain/kotlin/domain/Game.kt
Normal file
@@ -0,0 +1,21 @@
|
||||
package domain
|
||||
|
||||
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 }
|
||||
}
|
||||
Reference in New Issue
Block a user