From f21553067a9b584ad83edfc4c1cd3cbdc30f02ab Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Fri, 18 Sep 2020 01:27:29 +0200 Subject: Fix double military resolution in last age When a player had the copy guild move at the end of the game, the military conflicts were resolved twice. This fix prevents it. Resolves: https://github.com/joffrey-bion/seven-wonders/issues/41 --- sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sw-engine/src/main/kotlin/org') diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt index 60dc505b..1d4fab65 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt @@ -34,12 +34,14 @@ class Game internal constructor( private val preparedMoves: MutableMap = mutableMapOf() private var currentTurnInfo: List = emptyList() private var hands: Hands = Hands(emptyList()) + private var militaryConflictsResolved = false init { startNewAge() } private fun startNewAge() { + militaryConflictsResolved = false table.increaseCurrentAge() hands = decks.deal(table.currentAge, players.size) startNewTurn() @@ -196,7 +198,12 @@ class Game internal constructor( private fun endOfAgeReached(): Boolean = hands.isEmpty - private fun executeEndOfAgeEvents() = table.resolveMilitaryConflicts() + private fun executeEndOfAgeEvents() { + if (!militaryConflictsResolved) { + table.resolveMilitaryConflicts() + militaryConflictsResolved = true + } + } fun endOfGameReached(): Boolean = endOfAgeReached() && table.currentAge == LAST_AGE -- cgit