Resolved #3967 - City-states can no longer 'gift' you your unique units

This commit is contained in:
Yair Morgenstern 2021-06-03 22:25:27 +03:00
parent 98d551559b
commit 4b06a55bb5
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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)