Slightly change mechanics of simulateUntilWin (#2772)

* Slightly change mechanics of simulateUntilWin

* Forgot to turn off some debugging switch
This commit is contained in:
Alexander Korolyov
2020-06-25 21:32:00 +02:00
committed by GitHub
parent aa677042dd
commit 4c7970f5d7
3 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -40,7 +40,7 @@ class BasicTests {
!game.superchargedForDebug
&& !game.viewEntireMapForDebug
&& game.simulateUntilTurnForDebug <= 0
&& game.simulateUntilWinOrLose <= 0
&& !game.simulateUntilWin
&& !game.scenarioDebugSwitch)
}