diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 466ec6dde8..2d14baf889 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -45,6 +45,17 @@ class UncivGame( */ val simulateUntilTurnForDebug: Int = 0 + /** Simulate until any player wins or loses, + * or turns exceeds indicated number + * Does not update World View changes until finished. + * Set to 0 to disable. + */ + var simulateUntilWinOrLose: Int = 1000 + + /** Console log battles + */ + val alertBattle = true + lateinit var worldScreen: WorldScreen var music: Music? = null @@ -198,4 +209,3 @@ class LoadingScreen:CameraStageBaseScreen() { } } - diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index ee4322a2fc..c812788efc 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -84,6 +84,7 @@ class GameInfo { while (thisPlayer.playerType == PlayerType.AI || UncivGame.Current.simulateUntilTurnForDebug > turns + || UncivGame.Current.simulateUntilWinOrLose > turns // For multiplayer, if there are 3+ players and one is defeated, // we'll want to skip over their turn || (thisPlayer.isDefeated() && gameParameters.isOnlineMultiplayer) @@ -95,6 +96,19 @@ class GameInfo { if (thisPlayer.isBarbarian() && !gameParameters.noBarbarians && turns % 10 == 0) placeBarbarians() + + // exit simulation mode when player wins or loses + if (thisPlayer.isDefeated() || thisPlayer.victoryManager.hasWon() + && UncivGame.Current.simulateUntilWinOrLose != 0 + ) { + // stop simulation + UncivGame.Current.simulateUntilWinOrLose = turns + 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") + } + } } switchTurn() } @@ -369,4 +383,3 @@ class GameInfo { } - diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 874f2e418e..d1ad59da8a 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -33,8 +33,10 @@ object Battle { } fun attack(attacker: ICombatant, defender: ICombatant) { - println(attacker.getCivInfo().civName+" "+attacker.getName()+" attacked "+ - defender.getCivInfo().civName+" "+defender.getName()) + if (UncivGame.Current.alertBattle) { + println(attacker.getCivInfo().civName+" "+attacker.getName()+" attacked "+ + defender.getCivInfo().civName+" "+defender.getName()) + } val attackedTile = defender.getTile() if(attacker is MapUnitCombatant && attacker.getUnitType().isAirUnit()){