From 60809db065fb9856caf842d2bf6610b23d739aca Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sun, 13 Jun 2021 07:06:35 +0200 Subject: [PATCH] Updated Liberty branch to G&K (#4115) * Updated Liberty branch to G&K, improved modularity of uniques * Updated meritocracy to only affect non-occupied cities * Implemented requsted changes --- .../assets/jsons/Civ V - Vanilla/Buildings.json | 2 +- .../assets/jsons/Civ V - Vanilla/Policies.json | 14 +++++++------- core/src/com/unciv/logic/city/CityInfo.kt | 17 +++++++++-------- core/src/com/unciv/logic/city/CityStats.kt | 6 +++++- .../models/ruleset/tile/TileImprovement.kt | 16 +++++++++++----- 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Buildings.json b/android/assets/jsons/Civ V - Vanilla/Buildings.json index e9f97f748e..5e92438d2e 100644 --- a/android/assets/jsons/Civ V - Vanilla/Buildings.json +++ b/android/assets/jsons/Civ V - Vanilla/Buildings.json @@ -136,7 +136,7 @@ "culture": 1, "greatPersonPoints": {"production": 1}, "isWonder": true, - "uniques": ["Worker construction increased 25%","[2] free [Worker] units appear"], + "uniques": ["-[25]% tile improvement construction time","[2] free [Worker] units appear"], "requiredTech": "Masonry", "quote": "'O, let not the pains of death which come upon thee enter into my body. I am the god Tem, and I am the foremost part of the sky, and the power which protecteth me is that which is with all the gods forever.' - The Book of the Dead, translated by Sir Ernest Alfred Wallis Budge" }, diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 96b3d7cf3a..21273bb8bb 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -48,21 +48,21 @@ "uniques": ["[+1 Culture] [in all cities]"], "policies": [ { - "name": "Collective Rule", - "uniques": ["+[50]% Production when constructing [Settler] units [in capital]", "Free [Settler] appears"], + "name": "Republic", + "uniques": ["[+1 Production] [in all cities]", "+[5]% Production when constructing [Buildings]"], "row": 1, "column": 1 }, { "name": "Citizenship", - "uniques": ["Tile improvement speed +25%", "Free [Worker] appears"], + "uniques": ["-[25]% tile improvement construction time", "Free [Worker] appears"], "row": 1, "column": 4 }, { - "name": "Republic", - "uniques": ["[+1 Production] [in all cities]", "+[5]% Production when constructing [Buildings]"], - "requires": ["Collective Rule"], + "name": "Collective Rule", + "uniques": ["+[50]% Production when constructing [Settler] units [in capital]", "Free [Settler] appears"], + "requires": ["Republic"], "row": 2, "column": 1 }, @@ -75,7 +75,7 @@ }, { "name": "Meritocracy", - "uniques": ["[+1 Happiness] [in all cities connected to capital]", "Unhappiness from population decreased by [5]%"], + "uniques": ["[+1 Happiness] [in all cities connected to capital]", "Unhappiness from population decreased by [5]% [in all non-occupied cities]"], "requires": ["Citizenship"], "row": 2, "column": 5 diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index d094fd939c..03ff0d9262 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -467,14 +467,15 @@ class CityInfo { } fun matchesFilter(filter: String): Boolean { - return when { - filter == "in this city" -> true - filter == "in all cities" -> true - filter == "in all coastal cities" && getCenterTile().isCoastalTile() -> true - filter == "in capital" && isCapital() -> true - filter == "in all cities with a world wonder" && cityConstructions.getBuiltBuildings().any { it.isWonder } -> true - filter == "in all cities connected to capital" -> isConnectedToCapital() - filter == "in all cities with a garrison" && getCenterTile().militaryUnit != null -> true + return when (filter) { + "in this city" -> true + "in all cities" -> true + "in all coastal cities" -> getCenterTile().isCoastalTile() + "in capital" -> isCapital() + "in all non-occupied cities" -> !cityStats.hasExtraAnnexUnhappiness() || isPuppet + "in all cities with a world wonder" -> cityConstructions.getBuiltBuildings().any { it.isWonder } + "in all cities connected to capital" -> isConnectedToCapital() + "in all cities with a garrison" -> getCenterTile().militaryUnit != null else -> false } } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 017d8bf2de..24f5682d9c 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -195,6 +195,10 @@ class CityStats { for (unique in civInfo.getMatchingUniques("Unhappiness from population decreased by []%")) unhappinessFromCitizens *= (1 - unique.params[0].toFloat() / 100) + + for (unique in civInfo.getMatchingUniques("Unhappiness from population decreased by []% []")) + if (cityInfo.matchesFilter(unique.params[1])) + unhappinessFromCitizens *= (1 - unique.params[0].toFloat() / 100) newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier @@ -222,7 +226,7 @@ class CityStats { } - private fun hasExtraAnnexUnhappiness(): Boolean { + fun hasExtraAnnexUnhappiness(): Boolean { if (cityInfo.civInfo.civName == cityInfo.foundingCiv || cityInfo.foundingCiv == "" || cityInfo.isPuppet) return false return !cityInfo.containsBuildingUnique("Remove extra unhappiness from annexed cities") } diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 83d44358ac..2ca0b6ad07 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -28,11 +28,17 @@ class TileImprovement : NamedStats() { fun getTurnsToBuild(civInfo: CivilizationInfo): Int { var realTurnsToBuild = turnsToBuild.toFloat() * civInfo.gameInfo.gameParameters.gameSpeed.modifier - // todo UNIFY THESE - if (civInfo.hasUnique("Worker construction increased 25%")) - realTurnsToBuild *= 0.75f - if (civInfo.hasUnique("Tile improvement speed +25%")) - realTurnsToBuild *= 0.75f + for (unique in civInfo.getMatchingUniques("-[]% tile improvement construction time")) { + realTurnsToBuild *= 1 - unique.params[0].toFloat() / 100f + // Deprecated since 3.14.17 + if (civInfo.hasUnique("Worker construction increased 25%")) + realTurnsToBuild *= 0.75f + if (civInfo.hasUnique("Tile improvement speed +25%")) + realTurnsToBuild *= 0.75f + // + } + // In some weird cases it was possible for something to take 0 turns, leading to it instead never finishing + if (realTurnsToBuild < 1) realTurnsToBuild = 1f return realTurnsToBuild.roundToInt() }