From 0444a28657eb476719b098bb32bee180b41dce00 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 30 Jul 2020 19:56:43 +0300 Subject: [PATCH] Policy transformation --- .../jsons/Civ V - Vanilla/Policies.json | 7 ++++++- core/src/com/unciv/logic/city/CityStats.kt | 19 +++++++++++++++---- .../unciv/logic/civilization/CivInfoStats.kt | 2 +- .../unciv/logic/civilization/PolicyManager.kt | 5 ++--- core/src/com/unciv/models/ruleset/Building.kt | 17 ++--------------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 75c11b91..56730c70 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -154,7 +154,7 @@ "name": "Piety", "era": "Classical era", "effect": "Building time of culture buildings reduced by 15%", - "uniques": ["Production cost of [Culture] buildings reduced by [15]%"], + "uniques": ["+[15]% Production when constructing [Culture] buildings"], "policies": [ { "name": "Organized Religion", @@ -167,12 +167,14 @@ { "name": "Mandate Of Heaven", "effect": "50% of excess happiness added to culture towards policies", + "uniques": ["50% of excess happiness added to culture towards policies"], "row": 1, "column": 5 }, { "name": "Theocracy", "effect": "Temples give +10% gold", + "uniques": ["Temples give +10% gold"], "requires": ["Organized Religion"], "row": 2, "column": 1 @@ -180,6 +182,7 @@ { "name": "Reformation", "effect": "+33% culture in all cities with a world wonder, immediately enter a golden age", + "uniques": ["+33% culture in all cities with a world wonder", "Empire enters golden age"] "requires": ["Organized Religion"], "row": 2, "column": 3 @@ -187,6 +190,8 @@ { "name": "Free Religion", "effect": "+1 culture for each monument, temple and monastery. Gain a free policy.", + "uniques": ["[+1 Culture] from every [Monument]", "[+1 Culture] from every [Temple]", "[+1 Culture] from every [Monastery]", + "Free Social Policy"] "requires": ["Mandate Of Heaven","Reformation"], "row": 3, "column": 4 diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index b4e9f6aa..27391286 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -342,10 +342,21 @@ class CityStats { if (cityInfo.civInfo.hasUnique("+20% production when training melee units") && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) stats.production += 20 - if (policies.contains("Piety") - && listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name)) - stats.production += 15f - if (policies.contains("Reformation") && cityConstructions.getBuiltBuildings().any { it.isWonder }) + + if(currentConstruction is Building && !currentConstruction.isWonder) + for(unique in cityInfo.civInfo.getMatchingUniques("+[]% Production when constructing [] buildings")){ + val placeholderParams = unique.getPlaceholderParameters() + val stat = Stat.valueOf(placeholderParams[0]) + if(currentConstruction.isStatRelated(stat)) + stats.production += placeholderParams[1].toInt() + } + + if (currentConstruction is Building && currentConstruction.name == "Courthouse" + && cityInfo.civInfo.policies.hasEffect("+3 Happiness from every Courthouse. Build Courthouses in half the usual time.")) + stats.production += 100 + + if (cityConstructions.getBuiltBuildings().any { it.isWonder } + && cityInfo.civInfo.hasUnique("+33% culture in all cities with a world wonder")) stats.culture += 33f if (policies.contains("Commerce") && cityInfo.isCapital()) stats.gold += 25f diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 6a6bab2f..2d26ca8d 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -91,7 +91,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){ statMap["Transportation upkeep"] = Stats().apply { gold=- getTransportationUpkeep().toFloat()} statMap["Unit upkeep"] = Stats().apply { gold=- getUnitUpkeep().toFloat()} - if (civInfo.policies.hasEffect("50% of excess happiness added to culture towards policies")) { + if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) { val happiness = civInfo.getHappiness() if(happiness>0) statMap.add("Policies", Stats().apply { culture=happiness/2f }) } diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 185b5473..efad09d0 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -138,9 +138,8 @@ class PolicyManager { if (hasCapital && (unitName != Constants.settler || !civInfo.isOneCityChallenger())) civInfo.placeUnitNearTile(civInfo.getCapital().location, unitName) } - "+1 culture for each monument, temple and monastery. Gain a free policy." -> freePolicies++ - "Empire enters golden age", - "+33% culture in all cities with a world wonder, immediately enter a golden age" -> + "Gain a free policy" -> freePolicies++ + "Empire enters golden age" -> civInfo.goldenAges.enterGoldenAge() "Free Great Person" -> { if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++ diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 7f4c321d..90ff3061 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -143,9 +143,6 @@ class Building : NamedStats(), IConstruction{ stats.add(Stats.parse(placeholderParams[0])) } - if (adoptedPolicies.contains("Free Religion") && cultureBuildings.contains(baseBuildingName )) - stats.culture += 1f - if (adoptedPolicies.contains("Entrepreneurship") && hashSetOf("Mint", "Market", "Bank", "Stock Market").contains(baseBuildingName )) stats.science += 1f @@ -172,10 +169,10 @@ class Building : NamedStats(), IConstruction{ val adoptedPolicies = civInfo.policies.adoptedPolicies val baseBuildingName = getBaseBuilding(civInfo.gameInfo.ruleSet).name - if (adoptedPolicies.contains("Theocracy") && baseBuildingName == "Temple") + if (baseBuildingName == "Temple" && civInfo.hasUnique("Temples give +10% gold")) stats.gold = 10f - if (adoptedPolicies.contains("Free Thought") && baseBuildingName == "University") + if (baseBuildingName == "University" && adoptedPolicies.contains("Free Thought")) stats.science = 50f if(uniques.contains("+5% Production for every Trade Route with a City-State in the empire")) @@ -192,16 +189,6 @@ class Building : NamedStats(), IConstruction{ override fun getProductionCost(civInfo: CivilizationInfo): Int { var productionCost = cost.toFloat() - if(!isWonder) - for(unique in civInfo.getMatchingUniques("Production cost of [] buildings reduced by []%")){ - val placeholderParams = unique.getPlaceholderParameters() - val stat = Stat.valueOf(placeholderParams[0]) - if(this.isStatRelated(stat)) - productionCost *= (1f - placeholderParams[1].toFloat()/100) - } - - if (name == "Courthouse" && civInfo.policies.hasEffect("+3 Happiness from every Courthouse. Build Courthouses in half the usual time.")) - productionCost *= 0.5f if (civInfo.isPlayerCivilization()) { if (!isWonder)