From 04d4c9c9bf560ce0c7e5239bb7685117f22ccfa0 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 2 Aug 2020 16:17:20 +0300 Subject: [PATCH] Resolved #2929 - Can no longer destroy original capitals by nuke --- .../assets/jsons/Civ V - Vanilla/Nations.json | 3 +++ core/src/com/unciv/logic/battle/Battle.kt | 7 ++--- core/src/com/unciv/logic/city/CityStats.kt | 13 +++++----- .../diplomacy/DiplomacyManager.kt | 26 ++++++++++--------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Nations.json b/android/assets/jsons/Civ V - Vanilla/Nations.json index be05a0ed19..b74a215257 100644 --- a/android/assets/jsons/Civ V - Vanilla/Nations.json +++ b/android/assets/jsons/Civ V - Vanilla/Nations.json @@ -59,6 +59,7 @@ "outerColor": [181, 232, 232], "innerColor": [68,142,249], "unique": "HELLENIC_LEAGUE", + "uniques": ["City-State Influence degrades at half rate", "City-State Influence recovers at twice the normal rate"] "cities": ["Athens","Sparta","Corinth","Argos","Knossos","Mycenae","Pharsalos","Ephesus","Halicarnassus","Rhodes", "Eretria","Pergamon","Miletos","Megara","Phocaea","Sicyon","Tiryns","Samos","Mytilene","Chios", "Paros","Elis","Syracuse","Herakleia","Gortyn","Chalkis","Pylos","Pella","Naxos","Sicyon", @@ -83,6 +84,7 @@ "outerColor": [9, 112, 84], "innerColor": [255,255,255], "unique": "ART_OF_WAR", + "uniques": ["Great General provides double combat bonus", "[Great General] is earned [50]% faster"] "cities": ["Beijing","Shanghai","Guangzhou","Nanjing","Xian","Chengdu","Hangzhou","Tianjin","Macau","Shandong", "Kaifeng","Ningbo","Baoding","Yangzhou","Harbin","Chongqing","Luoyang","Kunming","Taipei","Shenyang", "Taiyuan","Tainan","Dalian","Lijiang","Wuxi","Suzhou","Maoming","Shaoguan","Yangjiang","Heyuan","Huangshi", @@ -111,6 +113,7 @@ "outerColor": [ 231, 213, 0], "innerColor": [98,10,210], "unique": "MONUMENT_BUILDERS", + "uniques": ["+[20]% Production when constructing [Wonders]"] "cities": ["Thebes","Memphis","Heliopolis","Elephantine","Alexandria","Pi-Ramesses","Giza","Byblos","Akhetaten", "Hieraconpolis","Abydos","Asyut","Avaris","Lisht","Buto","Edfu","Pithom","Busiris","Kahun","Athribis", "Mendes","Elashmunein","Tanis","Bubastis","Oryx","Sebennytus","Akhmin","Karnak","Luxor","El Kab","Armant", diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 919e0b1355..60ce3b0967 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -245,7 +245,8 @@ object Battle { if(thisCombatant.getCivInfo().isMajorCiv()) { var greatGeneralPointsModifier = 1f - if (thisCombatant.getCivInfo().nation.unique == UniqueAbility.ART_OF_WAR) + // Yeah sue me I didn't parse these params + if (thisCombatant.getCivInfo().hasUnique("[Great General] is earned [50]% faster")) greatGeneralPointsModifier += 0.5f if (thisCombatant.unit.hasUnique("Combat very likely to create Great Generals")) greatGeneralPointsModifier += 1f @@ -336,10 +337,10 @@ object Battle { val city = tile.getCity() if (city != null && city.location == tile.position) { city.health = 1 - if (city.population.population <= 5) { + if (city.population.population <= 5 && city.isOriginalCapital) { city.destroyCity() } else { - city.population.population -= 5 + city.population.population = max(city.population.population-5, 1) city.population.unassignExtraPopulation() continue } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index a4fb308366..ab7f742038 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -330,10 +330,10 @@ class CityStats { return stats } - private fun getStatPercentBonusesFromPolicies(cityConstructions: CityConstructions): Stats { + private fun getStatPercentBonusesFromPolicies(): Stats { val stats = Stats() - val currentConstruction = cityConstructions.getCurrentConstruction() + val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction() if (currentConstruction.name == Constants.settler && cityInfo.isCapital() && cityInfo.civInfo.hasUnique("Training of settlers increased +50% in capital")) stats.production += 50f @@ -353,12 +353,13 @@ class CityStats { val placeholderParams = unique.getPlaceholderParameters() val filter = placeholderParams[1] if (currentConstruction.name == filter - || (filter=="military units" && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian()) - || (filter=="Buildings" && currentConstruction is Building && !currentConstruction.isWonder)) + || (filter == "military units" && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian()) + || (filter == "Buildings" && currentConstruction is Building && !currentConstruction.isWonder) + || (filter == "Wonders" && currentConstruction is Building && currentConstruction.isWonder)) stats.production += placeholderParams[0].toInt() } - if (cityConstructions.getBuiltBuildings().any { it.isWonder } + if (cityInfo.cityConstructions.getBuiltBuildings().any { it.isWonder } && cityInfo.civInfo.hasUnique("+33% culture in all cities with a world wonder")) stats.culture += 33f if (cityInfo.civInfo.hasUnique("+25% gold in capital") && cityInfo.isCapital()) @@ -406,7 +407,7 @@ class CityStats { fun updateStatPercentBonusList() { val newStatPercentBonusList = LinkedHashMap() newStatPercentBonusList["Golden Age"] = getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge()) - newStatPercentBonusList["Policies"] = getStatPercentBonusesFromPolicies(cityInfo.cityConstructions) + newStatPercentBonusList["Policies"] = getStatPercentBonusesFromPolicies() newStatPercentBonusList["Buildings"] = getStatPercentBonusesFromBuildings() newStatPercentBonusList["Railroad"] = getStatPercentBonusesFromRailroad() newStatPercentBonusList["Marble"] = getStatPercentBonusesFromMarble() diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 672909c206..91e314911f 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -167,19 +167,22 @@ class DiplomacyManager() { return otherCivDiplomacy().getTurnsToRelationshipChange() if (civInfo.isCityState() && !otherCiv().isCityState()) { - val hasCityStateInfluenceBonus = otherCiv().nation.unique == UniqueAbility.HELLENIC_LEAGUE - val dropPerTurn = if(hasCityStateInfluenceBonus) .5f else 1f - - if (relationshipLevel() >= RelationshipLevel.Ally) - return ceil((influence - 60f) / dropPerTurn).toInt() + 1 - else if (relationshipLevel() >= RelationshipLevel.Friend) - return ceil((influence - 30f) / dropPerTurn).toInt() + 1 - else - return 0 + val dropPerTurn = getCityStateInfluenceDegradeRate() + when { + relationshipLevel() >= RelationshipLevel.Ally -> return ceil((influence - 60f) / dropPerTurn).toInt() + 1 + relationshipLevel() >= RelationshipLevel.Friend -> return ceil((influence - 30f) / dropPerTurn).toInt() + 1 + else -> return 0 + } } return 0 } + fun getCityStateInfluenceDegradeRate(): Float { + if(otherCiv().hasUnique("City-State Influence degrades at half rate")) + return .5f + else return 1f + } + fun canDeclareWar() = turnsToPeaceTreaty()==0 && diplomaticStatus != DiplomaticStatus.War //Used for nuke fun canAttack() = turnsToPeaceTreaty()==0 @@ -288,9 +291,8 @@ class DiplomacyManager() { private fun nextTurnCityStateInfluence() { val initialRelationshipLevel = relationshipLevel() - val hasCityStateInfluenceBonus = otherCiv().nation.unique == UniqueAbility.HELLENIC_LEAGUE - val increment = if (hasCityStateInfluenceBonus) 2f else 1f - val decrement = if (hasCityStateInfluenceBonus) .5f else 1f + val increment = if (otherCiv().hasUnique("City-State Influence recovers at twice the normal rate")) 2f else 1f + val decrement = getCityStateInfluenceDegradeRate() if (influence > restingPoint) influence = max(restingPoint, influence - decrement)