From 4b06a55bb5d7c92b95cbc0a76a69243041a39598 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 3 Jun 2021 22:25:27 +0300 Subject: [PATCH] Resolved #3967 - City-states can no longer 'gift' you your unique units --- core/src/com/unciv/logic/civilization/CivilizationInfo.kt | 4 ++-- .../unciv/logic/civilization/diplomacy/DiplomacyManager.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 23031b4223..0e7e304e0e 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -637,11 +637,11 @@ class CivilizationInfo { return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.modifier).toInt() } - fun giftMilitaryUnitTo(otherCiv: CivilizationInfo) { + fun gainMilitaryUnitFromCityState(otherCiv: CivilizationInfo) { val cities = NextTurnAutomation.getClosestCities(this, otherCiv) val city = cities.city1 val militaryUnit = city.cityConstructions.getConstructableUnits() - .filter { !it.unitType.isCivilian() && it.unitType.isLandUnit() } + .filter { !it.unitType.isCivilian() && it.unitType.isLandUnit() && it.uniqueTo==null } .toList().random() // placing the unit may fail - in that case stay quiet val placedUnit = placeUnitNearTile(city.location, militaryUnit.name) ?: return diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 9b69a917f7..6a31cdaf99 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -392,12 +392,13 @@ class DiplomacyManager() { if (!otherCivDiplomacy().hasFlag(DiplomacyFlags.ResearchAgreement)) sciencefromResearchAgreement() } + // This is confusingly named - in fact, the civ that has the flag set is the MAJOR civ DiplomacyFlags.ProvideMilitaryUnit.name -> { - // Do not unset the flag + // Do not unset the flag - they may return soon, and we'll continue from that point on if (civInfo.cities.isEmpty() || otherCiv().cities.isEmpty()) continue@loop else - civInfo.giftMilitaryUnitTo(otherCiv()) + civInfo.gainMilitaryUnitFromCityState(otherCiv()) } DiplomacyFlags.AgreedToNotSettleNearUs.name -> { addModifier(DiplomaticModifiers.FulfilledPromiseToNotSettleCitiesNearUs, 10f)