mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 08:49:22 +07:00
Slightly change mechanics of simulateUntilWin (#2772)
* Slightly change mechanics of simulateUntilWin * Forgot to turn off some debugging switch
This commit is contained in:

committed by
GitHub

parent
aa677042dd
commit
4c7970f5d7
@ -46,16 +46,17 @@ class UncivGame(
|
|||||||
*/
|
*/
|
||||||
val simulateUntilTurnForDebug: Int = 0
|
val simulateUntilTurnForDebug: Int = 0
|
||||||
|
|
||||||
/** Simulate until any player wins or loses,
|
/** Simulate until any player wins,
|
||||||
* or turns exceeds indicated number
|
* or turns exceeds indicated number
|
||||||
* Does not update World View changes until finished.
|
* 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
|
/** Console log battles
|
||||||
*/
|
*/
|
||||||
val alertBattle = true
|
val alertBattle = false
|
||||||
/** Debug new Scenario functionality
|
/** Debug new Scenario functionality
|
||||||
*/
|
*/
|
||||||
val scenarioDebugSwitch = false
|
val scenarioDebugSwitch = false
|
||||||
|
@ -11,7 +11,6 @@ import com.unciv.logic.map.TileMap
|
|||||||
import com.unciv.logic.trade.TradeOffer
|
import com.unciv.logic.trade.TradeOffer
|
||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
import com.unciv.models.metadata.GameParameters
|
import com.unciv.models.metadata.GameParameters
|
||||||
import com.unciv.models.metadata.Player
|
|
||||||
import com.unciv.models.ruleset.Difficulty
|
import com.unciv.models.ruleset.Difficulty
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
@ -36,6 +35,7 @@ class GameInfo {
|
|||||||
var oneMoreTurnMode=false
|
var oneMoreTurnMode=false
|
||||||
var currentPlayer=""
|
var currentPlayer=""
|
||||||
var gameId = UUID.randomUUID().toString() // random string
|
var gameId = UUID.randomUUID().toString() // random string
|
||||||
|
var simulateUntilWin = UncivGame.Current.simulateUntilWin
|
||||||
|
|
||||||
//region pure functions
|
//region pure functions
|
||||||
fun clone(): GameInfo {
|
fun clone(): GameInfo {
|
||||||
@ -84,8 +84,8 @@ class GameInfo {
|
|||||||
switchTurn()
|
switchTurn()
|
||||||
|
|
||||||
while (thisPlayer.playerType == PlayerType.AI
|
while (thisPlayer.playerType == PlayerType.AI
|
||||||
|| UncivGame.Current.simulateUntilTurnForDebug > turns
|
|| turns < UncivGame.Current.simulateUntilTurnForDebug
|
||||||
|| UncivGame.Current.simulateUntilWinOrLose > turns
|
|| (turns < UncivGame.Current.simulateMaxTurns && simulateUntilWin)
|
||||||
// For multiplayer, if there are 3+ players and one is defeated,
|
// For multiplayer, if there are 3+ players and one is defeated,
|
||||||
// we'll want to skip over their turn
|
// we'll want to skip over their turn
|
||||||
|| (thisPlayer.isDefeated() && gameParameters.isOnlineMultiplayer)
|
|| (thisPlayer.isDefeated() && gameParameters.isOnlineMultiplayer)
|
||||||
@ -98,17 +98,13 @@ class GameInfo {
|
|||||||
&& !gameParameters.noBarbarians
|
&& !gameParameters.noBarbarians
|
||||||
&& turns % 10 == 0) placeBarbarians()
|
&& turns % 10 == 0) placeBarbarians()
|
||||||
|
|
||||||
// exit simulation mode when player wins or loses
|
// exit simulation mode when player wins
|
||||||
if (thisPlayer.isDefeated() || thisPlayer.victoryManager.hasWon()
|
if (thisPlayer.victoryManager.hasWon() && simulateUntilWin) {
|
||||||
&& UncivGame.Current.simulateUntilWinOrLose != 0
|
|
||||||
) {
|
|
||||||
// stop simulation
|
// stop simulation
|
||||||
UncivGame.Current.simulateUntilWinOrLose = turns
|
simulateUntilWin = false
|
||||||
println("Simulation stopped on turn $turns")
|
println("Simulation stopped on turn $turns")
|
||||||
for (civ in UncivGame.Current.gameInfo.civilizations) {
|
val victoryType = thisPlayer.victoryManager.hasWonVictoryType()
|
||||||
val victoryType = civ.victoryManager.hasWonVictoryType()
|
println("$thisPlayer won $victoryType victory")
|
||||||
if (civ.victoryManager.hasWon()) println("$civ won $victoryType victory")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switchTurn()
|
switchTurn()
|
||||||
@ -117,6 +113,9 @@ class GameInfo {
|
|||||||
currentPlayer = thisPlayer.civName
|
currentPlayer = thisPlayer.civName
|
||||||
currentPlayerCiv = getCivilization(currentPlayer)
|
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.
|
// 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)
|
notifyOfCloseEnemyUnits(thisPlayer)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class BasicTests {
|
|||||||
!game.superchargedForDebug
|
!game.superchargedForDebug
|
||||||
&& !game.viewEntireMapForDebug
|
&& !game.viewEntireMapForDebug
|
||||||
&& game.simulateUntilTurnForDebug <= 0
|
&& game.simulateUntilTurnForDebug <= 0
|
||||||
&& game.simulateUntilWinOrLose <= 0
|
&& !game.simulateUntilWin
|
||||||
&& !game.scenarioDebugSwitch)
|
&& !game.scenarioDebugSwitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user