diff options
Diffstat (limited to 'sw-engine')
2 files changed, 5 insertions, 8 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt index dfc69a41..82c23a72 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt @@ -27,9 +27,8 @@ enum class SpecialAbility { */ COPY_GUILD { override fun computePoints(player: Player): Int { - val copiedGuild = player.board.copiedGuild - ?: throw IllegalStateException("The copied Guild has not been chosen, cannot compute points") - return copiedGuild.effects.sumBy { it.computePoints(player) } + // there can be no copiedGuild if no neighbour had any guild cards + return player.board.copiedGuild?.effects?.sumBy { it.computePoints(player) } ?: 0 } }; diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt index 50be6c24..978be53b 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt @@ -13,7 +13,6 @@ import org.luxons.sevenwonders.engine.test.testTable import org.luxons.sevenwonders.model.boards.RelativeBoardPosition import org.luxons.sevenwonders.model.cards.Color import kotlin.test.assertEquals -import kotlin.test.assertFailsWith import kotlin.test.assertTrue @RunWith(Theories::class) @@ -53,13 +52,12 @@ class SpecialAbilityActivationTest { assertEquals(directPointsFromGuildCard, effect.computePoints(player)) } + // there can be no copiedGuild if no neighbour had any guild cards @Test - fun computePoints_copyGuild_failWhenNoChosenGuild() { + fun computePoints_copyGuild_noPointWhenNoChosenGuild() { val effect = SpecialAbilityActivation(SpecialAbility.COPY_GUILD) val player = SimplePlayer(0, testTable(5)) - assertFailsWith<IllegalStateException> { - effect.computePoints(player) - } + assertEquals(0, effect.computePoints(player)) } companion object { |