diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 1ec943cd55..5031aa720a 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -46,16 +46,17 @@ class UncivGame( */ val simulateUntilTurnForDebug: Int = 0 - /** Simulate until any player wins or loses, + /** Simulate until any player wins, * or turns exceeds indicated number * Does not update World View changes until finished. - * Set to 0 to disable. + * Set false to disable. */ - var simulateUntilWinOrLose: Int = 0 + val simulateMaxTurns: Int = 2000 + val simulateUntilWin = false /** Console log battles */ - val alertBattle = true + val alertBattle = false /** Debug new Scenario functionality */ val scenarioDebugSwitch = false diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 437f7c8146..52fb0227c1 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -11,7 +11,6 @@ import com.unciv.logic.map.TileMap import com.unciv.logic.trade.TradeOffer import com.unciv.logic.trade.TradeType import com.unciv.models.metadata.GameParameters -import com.unciv.models.metadata.Player import com.unciv.models.ruleset.Difficulty import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache @@ -36,6 +35,7 @@ class GameInfo { var oneMoreTurnMode=false var currentPlayer="" var gameId = UUID.randomUUID().toString() // random string + var simulateUntilWin = UncivGame.Current.simulateUntilWin //region pure functions fun clone(): GameInfo { @@ -84,8 +84,8 @@ class GameInfo { switchTurn() while (thisPlayer.playerType == PlayerType.AI - || UncivGame.Current.simulateUntilTurnForDebug > turns - || UncivGame.Current.simulateUntilWinOrLose > turns + || turns < UncivGame.Current.simulateUntilTurnForDebug + || (turns < UncivGame.Current.simulateMaxTurns && simulateUntilWin) // For multiplayer, if there are 3+ players and one is defeated, // we'll want to skip over their turn || (thisPlayer.isDefeated() && gameParameters.isOnlineMultiplayer) @@ -98,17 +98,13 @@ class GameInfo { && !gameParameters.noBarbarians && turns % 10 == 0) placeBarbarians() - // exit simulation mode when player wins or loses - if (thisPlayer.isDefeated() || thisPlayer.victoryManager.hasWon() - && UncivGame.Current.simulateUntilWinOrLose != 0 - ) { + // exit simulation mode when player wins + if (thisPlayer.victoryManager.hasWon() && simulateUntilWin) { // stop simulation - UncivGame.Current.simulateUntilWinOrLose = turns + simulateUntilWin = false println("Simulation stopped on turn $turns") - for (civ in UncivGame.Current.gameInfo.civilizations) { - val victoryType = civ.victoryManager.hasWonVictoryType() - if (civ.victoryManager.hasWon()) println("$civ won $victoryType victory") - } + val victoryType = thisPlayer.victoryManager.hasWonVictoryType() + println("$thisPlayer won $victoryType victory") } } switchTurn() @@ -117,6 +113,9 @@ class GameInfo { currentPlayer = thisPlayer.civName currentPlayerCiv = getCivilization(currentPlayer) + if (turns == UncivGame.Current.simulateMaxTurns && UncivGame.Current.simulateUntilWin) + println ("Max simulation turns reached $turns: Draw") + // Start our turn immediately before the player can made decisions - affects whether our units can commit automated actions and then be attacked immediately etc. notifyOfCloseEnemyUnits(thisPlayer) } diff --git a/tests/src/com/unciv/testing/BasicTests.kt b/tests/src/com/unciv/testing/BasicTests.kt index 20cfb421a6..e1c54b423e 100644 --- a/tests/src/com/unciv/testing/BasicTests.kt +++ b/tests/src/com/unciv/testing/BasicTests.kt @@ -40,7 +40,7 @@ class BasicTests { !game.superchargedForDebug && !game.viewEntireMapForDebug && game.simulateUntilTurnForDebug <= 0 - && game.simulateUntilWinOrLose <= 0 + && !game.simulateUntilWin && !game.scenarioDebugSwitch) }