All trades are now cancelled when a civ is defeated

This commit is contained in:
Yair Morgenstern 2019-04-24 20:48:32 +03:00
parent bda375f441
commit c3a00a0f5e
3 changed files with 16 additions and 3 deletions

View file

@ -4808,6 +4808,8 @@
German:"[civName] hat uns den Krieg erklärt!" German:"[civName] hat uns den Krieg erklärt!"
} }
"[tradeOffer] from [otherCivName] has ended":{}
"[leaderName] of [nation]":{ // e.g. Ramasses of Egypt, Napoleon of France "[leaderName] of [nation]":{ // e.g. Ramasses of Egypt, Napoleon of France
Italian:"[leaderName] dell'Impero [nation]" //es. Ramses II dell'Impero egiziano, Napoleone dell'Impero francese (so it should be [adjective] instead of [nation] Italian:"[leaderName] dell'Impero [nation]" //es. Ramses II dell'Impero egiziano, Napoleone dell'Impero francese (so it should be [adjective] instead of [nation]
German:"[leaderName] von [nation]" German:"[leaderName] von [nation]"

View file

@ -196,9 +196,7 @@ class Battle(val gameInfo:GameInfo) {
if(city.cityConstructions.isBuilt("Palace")){ if(city.cityConstructions.isBuilt("Palace")){
city.cityConstructions.removeBuilding("Palace") city.cityConstructions.removeBuilding("Palace")
if(enemyCiv.isDefeated()) { if(enemyCiv.isDefeated()) {
for(civ in gameInfo.civilizations) enemyCiv.destroy()
civ.addNotification("The civilization of [${enemyCiv.civName}] has been destroyed!", null, Color.RED)
enemyCiv.getCivUnits().forEach { it.destroy() }
attacker.getCivInfo().popupAlerts.add(PopupAlert(AlertType.Defeated,enemyCiv.civName)) attacker.getCivInfo().popupAlerts.add(PopupAlert(AlertType.Defeated,enemyCiv.civName))
} }
else if(enemyCiv.cities.isNotEmpty()){ else if(enemyCiv.cities.isNotEmpty()){

View file

@ -508,5 +508,18 @@ class CivilizationInfo {
} }
} }
fun destroy(){
for(civ in gameInfo.civilizations)
civ.addNotification("The civilization of [$civName] has been destroyed!", null, Color.RED)
getCivUnits().forEach { it.destroy() }
tradeRequests.clear() // if we don't do this then there could be resources taken by "pending" trades forever
for(diplomacyManager in diplomacy.values){
diplomacyManager.trades.clear()
diplomacyManager.otherCiv().getDiplomacyManager(this).trades.clear()
for(tradeRequest in diplomacyManager.otherCiv().tradeRequests.filter { it.requestingCiv==civName })
diplomacyManager.otherCiv().tradeRequests.remove(tradeRequest) // it would be really weird to get a trade request from a dead civ
}
}
//endregion //endregion
} }