mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-02 08:09:28 +07:00
Resolve #11752 - fix crash in spy automation
This commit is contained in:
@ -81,13 +81,14 @@ class EspionageAutomation(val civInfo: Civilization) {
|
|||||||
spy.moveTo(civInfo.cities.filter { spy.canMoveTo(it) }.randomOrNull())
|
spy.moveTo(civInfo.cities.filter { spy.canMoveTo(it) }.randomOrNull())
|
||||||
return spy.action == SpyAction.CounterIntelligence
|
return spy.action == SpyAction.CounterIntelligence
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkIfShouldStageCoup(spy: Spy) {
|
private fun checkIfShouldStageCoup(spy: Spy) {
|
||||||
if (!spy.canDoCoup()) return
|
if (!spy.canDoCoup()) return
|
||||||
if (spy.getCoupChanceOfSuccess(false) < .7) return
|
if (spy.getCoupChanceOfSuccess(false) < .7) return
|
||||||
val allyCiv = spy.getCity().civ.getAllyCiv()?.let { civInfo.gameInfo.getCivilization(it) }
|
val allyCiv = spy.getCity().civ.getAllyCiv()?.let { civInfo.gameInfo.getCivilization(it) }
|
||||||
// Don't coup ally city-states
|
// Don't coup city-states whose allies are out friends
|
||||||
if (allyCiv != null && civInfo.getDiplomacyManager(allyCiv).isRelationshipLevelGE(RelationshipLevel.Friend)) return
|
if (allyCiv != null && civInfo.knows(allyCiv)
|
||||||
|
&& civInfo.getDiplomacyManager(allyCiv).isRelationshipLevelGE(RelationshipLevel.Friend)) return
|
||||||
val spies = civInfo.espionageManager.spyList
|
val spies = civInfo.espionageManager.spyList
|
||||||
val randomSeed = spies.size + spies.indexOf(spy) + civInfo.gameInfo.turns
|
val randomSeed = spies.size + spies.indexOf(spy) + civInfo.gameInfo.turns
|
||||||
val randomAction = Random(randomSeed).nextInt(100)
|
val randomAction = Random(randomSeed).nextInt(100)
|
||||||
|
Reference in New Issue
Block a user