Skip to content

Commit

Permalink
Resolved yairm210#12546 - Spies assigned to cities moved to other civ…
Browse files Browse the repository at this point in the history
…s are returned to hideout
  • Loading branch information
yairm210 committed Dec 2, 2024
1 parent b1f1998 commit cff67dd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions android/assets/jsons/translations/template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ Do you want to stage a coup in [civName] with a [percent]% chance of success? =
# Spy fleeing city
After the city of [cityName] was destroyed, your spy [spyName] has fled back to our hideout. =
After the city of [cityName] was conquered, your spy [spyName] has fled back to our hideout. =
After the city of [cityName] was taken over, your spy [spyName] has fled back to our hideout. =
Due to the chaos ensuing in [cityName], your spy [spyName] has fled back to our hideout. =
# Promotions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ class CityConquestFunctions(val city: City) {
// Remove their free buildings from this city and remove free buildings provided by the city from their cities
removeBuildingsOnMoveToCiv()

// catch-all - should ideally not happen as we catch the individual cases with an appropriate notification
city.espionage.removeAllPresentSpies(SpyFleeReason.Other)


// Place palace for newCiv if this is the only city they have.
if (newCiv.cities.size == 1) newCiv.moveCapitalTo(city, null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.unciv.logic.city.managers
import com.unciv.logic.IsPartOfGameInfoSerialization
import com.unciv.logic.city.City
import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.NotificationCategory
import com.unciv.logic.civilization.NotificationIcon
import com.unciv.models.Spy

enum class SpyFleeReason {
CityDestroyed,
CityCaptured,
CityBought,
CityTakenOverByMarriage,
Other
}

Expand Down Expand Up @@ -38,6 +38,7 @@ class CityEspionageManager : IsPartOfGameInfoSerialization {
val notificationString = when (reason) {
SpyFleeReason.CityDestroyed -> "After the city of [${city.name}] was destroyed, your spy [${spy.name}] has fled back to our hideout."
SpyFleeReason.CityCaptured -> "After the city of [${city.name}] was conquered, your spy [${spy.name}] has fled back to our hideout."
SpyFleeReason.CityBought, SpyFleeReason.CityTakenOverByMarriage -> "After the city of [${city.name}] was taken over, your spy [${spy.name}] has fled back to our hideout."
else -> "Due to the chaos ensuing in [${city.name}], your spy [${spy.name}] has fled back to our hideout."
}
spy.addNotification(notificationString)
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/city/managers/CityTurnManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CityTurnManager(val city: City) {
.sumOf { it.params[0].toInt() - 1 }

if (city.population.population <= removedPopulation) {
city.espionage.removeAllPresentSpies(SpyFleeReason.CityCaptured)
city.espionage.removeAllPresentSpies(SpyFleeReason.Other)
city.civ.addNotification(
"[${city.name}] has been razed to the ground!",
city.location, NotificationCategory.General,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.unciv.logic.civilization.diplomacy
import com.unciv.Constants
import com.unciv.logic.automation.civilization.NextTurnAutomation
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.city.managers.SpyFleeReason
import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.CivFlags
import com.unciv.logic.civilization.Civilization
Expand Down Expand Up @@ -371,18 +372,22 @@ class CityStateFunctions(val civInfo: Civilization) {
return

otherCiv.addGold(-getDiplomaticMarriageCost())

val notificationLocation = civInfo.getCapital()!!.location
otherCiv.addNotification("We have married into the ruling family of [${civInfo.civName}], bringing them under our control.",
notificationLocation,
NotificationCategory.Diplomacy, civInfo.civName,
NotificationIcon.Diplomacy, otherCiv.civName)

for (civ in civInfo.gameInfo.civilizations.filter { it != otherCiv })
civ.addNotification("[${otherCiv.civName}] has married into the ruling family of [${civInfo.civName}], bringing them under their control.",
notificationLocation,
NotificationCategory.Diplomacy, civInfo.civName,
NotificationIcon.Diplomacy, otherCiv.civName)

for (unit in civInfo.units.getCivUnits())
unit.gift(otherCiv)


// Make sure this CS can never be liberated
civInfo.gameInfo.getCities().filter {
Expand All @@ -393,6 +398,7 @@ class CityStateFunctions(val civInfo: Civilization) {
}

for (city in civInfo.cities) {
city.espionage.removeAllPresentSpies(SpyFleeReason.CityTakenOverByMarriage)
city.moveToCiv(otherCiv)
city.isPuppet = true // Human players get a popup that allows them to annex instead
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/com/unciv/logic/trade/TradeLogic.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.unciv.logic.trade

import com.unciv.Constants
import com.unciv.logic.city.managers.SpyFleeReason
import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.PopupAlert
Expand Down Expand Up @@ -106,6 +107,8 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
}
TradeOfferType.City -> {
val city = from.cities.first { it.id == offer.name }

city.espionage.removeAllPresentSpies(SpyFleeReason.CityBought)
city.moveToCiv(to)
city.getCenterTile().getUnits().toList()
.forEach { it.movement.teleportToClosestMoveableTile() }
Expand Down

0 comments on commit cff67dd

Please sign in to comment.