From f571fecb586059221a34743443a007edbd2b6f41 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 8 Sep 2018 18:37:25 +0800 Subject: [PATCH] fixes of 1 -> 8 and 8 -> 1 operations --- .../PsychomatrixBase/domain/entities/operations/Operation.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/entities/operations/Operation.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/entities/operations/Operation.kt index fb1220a..ff647c1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/entities/operations/Operation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/entities/operations/Operation.kt @@ -95,7 +95,7 @@ object FourGrowTwo : Operation() { object EightGrowOne : Operation() { override fun canConvert(numbers: List, changesHistory: List): Boolean { - return numbers[8] > 0 + return numbers[8] > changesHistory.count { it == OneGrowEight } && (TwoGrowFour.canConvert(numbers, changesHistory) || FourGrowTwo.canConvert(numbers, changesHistory)) } override fun canInvert(numbers: List, changesHistory: List): Boolean { @@ -128,7 +128,7 @@ object EightGrowOne : Operation() { object OneGrowEight : Operation() { override fun canConvert(numbers: List, changesHistory: List): Boolean { - return numbers[1] > 1 + return numbers[1] / 2 > changesHistory.count { it == EightGrowOne } } override fun canInvert(numbers: List, changesHistory: List): Boolean { return numbers[8] > 0 && changesHistory.contains(this)