Fixed spies errors (#11031)

This commit is contained in:
Oskar Niesen 2024-01-28 03:06:04 -06:00 committed by GitHub
parent 88034e6d02
commit 7efc71bd28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 15 deletions

View File

@ -526,18 +526,7 @@ object Battle {
if (civilianUnit != null) BattleUnitCapture.captureCivilianUnit(attacker, MapUnitCombatant(civilianUnit!!), checkDefeat = false)
for (airUnit in airUnits.toList()) airUnit.destroy()
}
// Move all spies in the city
if (attackerCiv.gameInfo.isEspionageEnabled()) {
for (civ in attackerCiv.gameInfo.civilizations.filter { it.isMajorCiv() }) {
for (spy in civ.espionageManager.spyList) {
if (spy.getLocation() == city) {
spy.moveTo(null)
}
}
}
}
val stateForConditionals = StateForConditionals(civInfo = attackerCiv, city=city, unit = attacker.unit, ourCombatant = attacker, attackedTile = city.getCenterTile())
for (unique in attacker.getMatchingUniques(UniqueType.CaptureCityPlunder, stateForConditionals, true)) {
attackerCiv.addStat(

View File

@ -79,6 +79,8 @@ class CityConquestFunctions(val city: City) {
* should go in `this.moveToCiv()`, which is called by `this.conquerCity()`.
*/
private fun conquerCity(conqueringCiv: Civilization, conqueredCiv: Civilization, receivingCiv: Civilization) {
city.espionage.removeAllPresentSpies(SpyFleeReason.CityCaptured)
val goldPlundered = getGoldForCapturingCity(conqueringCiv)
conqueringCiv.addGold(goldPlundered)
conqueringCiv.addNotification("Received [$goldPlundered] Gold for capturing [${city.name}]",
@ -105,8 +107,6 @@ class CityConquestFunctions(val city: City) {
// reconquering or liberating city in resistance so eliminate it
city.removeFlag(CityFlags.Resistance)
}
city.espionage.removeAllPresentSpies(SpyFleeReason.CityCaptured)
}

View File

@ -125,6 +125,7 @@ class CityTurnManager(val city: City) {
city.population.addPopulation(-1 * removedPopulation)
if (city.population.population <= 0) {
city.espionage.removeAllPresentSpies(SpyFleeReason.CityCaptured)
city.civ.addNotification(
"[${city.name}] has been razed to the ground!",
city.location, NotificationCategory.General,

View File

@ -29,7 +29,7 @@ class EspionageManager : IsPartOfGameInfoSerialization {
}
fun endTurn() {
for (spy in spyList)
for (spy in spyList.toList())
spy.endTurn()
}