From 9c66154a443b4563ce27f84c7e327c3f42633638 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sun, 12 Sep 2021 20:48:28 +0200 Subject: [PATCH] Updated piety policy tree (#5195) * Added piety policy tree * Misread an ability * Fixed filter --- .../jsons/Civ V - Vanilla/Policies.json | 29 +++++++------------ .../com/unciv/logic/BackwardCompatibility.kt | 7 +++++ .../unciv/logic/civilization/CivInfoStats.kt | 17 ++++++++--- .../unciv/logic/civilization/PolicyManager.kt | 11 +++++++ .../com/unciv/models/ruleset/unit/BaseUnit.kt | 1 + 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index f8a1e1dc9b..d0cb5932ed 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -135,24 +135,24 @@ },{ "name": "Piety", "era": "Classical era", - "uniques": ["+[15]% Production when constructing [Culture] buildings", "Incompatible with [Rationalism]"], + "uniques": ["+[100]% Production when constructing [Shrine] buildings", "+[100]% Production when constructing [Temple] buildings", + "Incompatible with [Rationalism]"], "policies": [ { "name": "Organized Religion", - "uniques": ["[+1 Happiness] from every [Monument]","[+1 Happiness] from every [Amphitheater]", - "[+1 Happiness] from every [Monastery]"], + "uniques": ["[+1 Faith] from every [Shrine]","[+1 Faith] from every [Temple]"], "row": 1, "column": 2 }, { "name": "Mandate Of Heaven", - "uniques": ["50% of excess happiness added to culture towards policies"], + "uniques": ["[50]% of excess happiness converted to [Culture]"], "row": 1, "column": 5 }, { "name": "Theocracy", - "uniques": ["+[10]% [Gold] from every [Amphitheater]"], + "uniques": ["+[10]% [Gold] from every [Temple]"], "requires": ["Organized Religion"], "row": 2, "column": 1 @@ -166,26 +166,19 @@ }, { "name": "Free Religion", - "uniques": ["[+1 Culture] from every [Monument]", "[+1 Culture] from every [Amphitheater]", "[+1 Culture] from every [Monastery]", - "Free Social Policy"], - "requires": ["Mandate Of Heaven","Reformation"], + "uniques": ["Culture cost of adopting new Policies reduced by [10]%"], + "requires": ["Mandate Of Heaven", "Reformation"], "row": 3, "column": 4 }, { "name": "Piety Complete", - "uniques": ["Culture cost of adopting new Policies reduced by [10]%"] + "uniques": ["[Faith] cost of purchasing items in cities [-20]%", "[+3 Gold, +3 Culture] from every [Holy site]"] } ] }, { - "name": "Patronage ", - // Yes, there is a space behind this word, and yes, this is necessary - // This is, because at the time of writing there existed another policy called 'Patronage' that was recently deprecated - // It would, however, still be possible for save-files to contain this policy - // Therefore, we had to differentiate between these two, and this was the least intrusive way to do so - // NOTE: If you remove the space here, also remove the extra space between 'patronage' and 'complete' in the 'patronage complete' policy. - // Otherwise, weird stuff will happen. + "name": "Patronage", "era": "Classical era", "uniques": ["City-State Influence degrades [25]% slower"], "policies": [ @@ -224,11 +217,9 @@ "column": 4 }, { - "name": "Patronage Complete", - // This extra space is intentional, see above. + "name": "Patronage Complete", "uniques": ["Influence of all other civilizations with all city-states degrades [33]% faster", "Triggers the following global alert: [Our influence with City-States has started dropping faster!]"] - // This triggers a global alert in the G&K game also, based on my memory of playing it } ] }, diff --git a/core/src/com/unciv/logic/BackwardCompatibility.kt b/core/src/com/unciv/logic/BackwardCompatibility.kt index 111c97ff8a..a3dfbf09ed 100644 --- a/core/src/com/unciv/logic/BackwardCompatibility.kt +++ b/core/src/com/unciv/logic/BackwardCompatibility.kt @@ -65,6 +65,13 @@ object BackwardCompatibility { for (tech in civInfo.tech.techsResearched.toList()) if (!ruleSet.technologies.containsKey(tech)) civInfo.tech.techsResearched.remove(tech) + for (policy in civInfo.policies.adoptedPolicies.toList()) + if (!ruleSet.policies.containsKey(policy) + // Converstion code for deprecated policies since 3.16.15 + && !(policy == "Patronage " || policy == "Patronage Complete") + // + ) + civInfo.policies.adoptedPolicies.remove(policy) } } diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 188a9c633f..5a7a02ecaa 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -178,10 +178,19 @@ class CivInfoStats(val civInfo: CivilizationInfo) { ) } - - if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) { - val happiness = civInfo.getHappiness() - if (happiness > 0) statMap.add("Policies", Stats(culture = happiness / 2f)) + // Deprecated since 3.16.15 + if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) { + val happiness = civInfo.getHappiness() + if (happiness > 0) statMap.add("Policies", Stats(culture = happiness / 2f)) + } + // + + if (civInfo.getHappiness() > 0) { + val excessHappinessConversion = Stats() + for (unique in civInfo.getMatchingUniques("[]% of excess happiness converted to []")) { + excessHappinessConversion.add(Stat.valueOf(unique.params[1]), (unique.params[0].toInt() / 100 * civInfo.getHappiness()).toFloat()) + } + statMap.add("Policies", excessHappinessConversion) } // negative gold hurts science diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 460989d45e..eb15e84c4e 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -50,6 +50,17 @@ class PolicyManager { fun getPolicyByName(name: String): Policy = civInfo.gameInfo.ruleSet.policies[name]!! fun setTransients() { + // Deprecated "Patronage " policy since 3.16.15 + if (adoptedPolicies.contains("Patronage ")) { + adoptedPolicies.remove("Patronage ") + adoptedPolicies.add("Patronage") + } + if (adoptedPolicies.contains("Patronage Complete")) { + adoptedPolicies.remove("Patronage Complete") + adoptedPolicies.add("Patronage Complete") + } + // + for (policyName in adoptedPolicies) addPolicyToTransients(getPolicyByName(policyName)) } diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 4db48b8417..b7724dfd2c 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -476,6 +476,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText { "Nuclear Weapon" -> isNuclearWeapon() "Great Person", "Great" -> isGreatPerson() + "Religious" -> uniques.contains("Religious Unit") else -> { if (getType().matchesFilter(filter)) return true if (