diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-09-18 01:27:29 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-09-18 01:27:29 +0200 |
commit | f21553067a9b584ad83edfc4c1cd3cbdc30f02ab (patch) | |
tree | 68ab4475654d3a1d66a23c1d8f8c12d90681856b | |
parent | Upgrade to Krossbow 0.41.0 (diff) | |
download | seven-wonders-f21553067a9b584ad83edfc4c1cd3cbdc30f02ab.tar.gz seven-wonders-f21553067a9b584ad83edfc4c1cd3cbdc30f02ab.tar.bz2 seven-wonders-f21553067a9b584ad83edfc4c1cd3cbdc30f02ab.zip |
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
-rw-r--r-- | sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt | 9 |
1 files changed, 8 insertions, 1 deletions
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<Int, Move> = mutableMapOf() private var currentTurnInfo: List<PlayerTurnInfo> = 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 |