mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-28 21:58:54 +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())
|
||||
return spy.action == SpyAction.CounterIntelligence
|
||||
}
|
||||
|
||||
|
||||
private fun checkIfShouldStageCoup(spy: Spy) {
|
||||
if (!spy.canDoCoup()) return
|
||||
if (spy.getCoupChanceOfSuccess(false) < .7) return
|
||||
val allyCiv = spy.getCity().civ.getAllyCiv()?.let { civInfo.gameInfo.getCivilization(it) }
|
||||
// Don't coup ally city-states
|
||||
if (allyCiv != null && civInfo.getDiplomacyManager(allyCiv).isRelationshipLevelGE(RelationshipLevel.Friend)) return
|
||||
// Don't coup city-states whose allies are out friends
|
||||
if (allyCiv != null && civInfo.knows(allyCiv)
|
||||
&& civInfo.getDiplomacyManager(allyCiv).isRelationshipLevelGE(RelationshipLevel.Friend)) return
|
||||
val spies = civInfo.espionageManager.spyList
|
||||
val randomSeed = spies.size + spies.indexOf(spy) + civInfo.gameInfo.turns
|
||||
val randomAction = Random(randomSeed).nextInt(100)
|
||||
|
Reference in New Issue
Block a user