From 362ca7c1e3bc147408f23785bfb0dbadba21443f Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 30 Jul 2020 22:07:05 +0300 Subject: [PATCH] More policy conversions, only 3 trees left! --- .../assets/jsons/Civ V - Vanilla/Buildings.json | 2 +- .../assets/jsons/Civ V - Vanilla/Policies.json | 16 +++++++++++++--- core/src/com/unciv/logic/city/CityInfo.kt | 2 +- core/src/com/unciv/logic/city/CityStats.kt | 4 ++-- .../unciv/logic/civilization/CivInfoStats.kt | 3 ++- .../unciv/logic/civilization/PolicyManager.kt | 3 +-- core/src/com/unciv/logic/map/TileInfo.kt | 15 +++++++++++---- core/src/com/unciv/models/ruleset/Building.kt | 17 +++++++++-------- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 5 +++-- .../unciv/ui/worldscreen/unit/UnitActions.kt | 2 +- 10 files changed, 44 insertions(+), 25 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Buildings.json b/android/assets/jsons/Civ V - Vanilla/Buildings.json index c54ec54352..825dacb739 100644 --- a/android/assets/jsons/Civ V - Vanilla/Buildings.json +++ b/android/assets/jsons/Civ V - Vanilla/Buildings.json @@ -756,7 +756,7 @@ "gold": 4, "greatPersonPoints": {"gold": 2}, "isWonder": true, - "uniques": ["-15% to purchasing items in cities"], + "uniques": ["Cost of purchasing items in cities reduced by [15]%"], "requiredTech": "Industrialization", "quote": "'To achieve great things, two things are needed: a plan, and not quite enough time.' - Leonard Bernstein" }, diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 56730c707e..378f9f846f 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -3,7 +3,7 @@ "name": "Tradition", "era": "Ancient era", "effect": "+3 culture in capital and increased rate of border expansion", - "uniques": ["+3 culture in capital", "Increased rate of border expansion"], + "uniques": ["[+3 Culture] in capital", "Increased rate of border expansion"], "policies": [ { "name": "Aristocracy", @@ -198,7 +198,8 @@ }, { "name": "Piety Complete", - "effect": "Reduce culture cost of future policies by 10%" + "effect": "Reduce culture cost of future policies by 10%", + "uniques": ["Culture cost of adopting new Policies reduced by 10%"] } ] },/*{ @@ -248,23 +249,28 @@ { "name": "Commerce", "effect": "+25% gold in capital", + "uniques": ["+25% gold in capital"], "era": "Medieval era", "policies": [ { "name": "Trade Unions", "effect": "Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes", + "uniques": ["Maintenance on roads & railroads reduced by 33%", "+2 Gold from all trade routes"] "row": 1, "column": 2 }, { "name": "Mercantilism", "effect": "-25% to purchasing items in cities", + "uniques": ["Cost of purchasing items in cities reduced by [25]%"] "row": 1, "column": 5 }, { "name": "Entrepreneurship", "effect": "Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange.", + "uniques": ["Great Merchants are earned 25% faster", "[+1 Science] from every [Mint]", "[+1 Science] from every [Market]", + "[+1 Science] from every [Bank]", "[+1 Science] from every [Stock Exchange]" ], "requires": ["Trade Unions"], "row": 2, "column": 2 @@ -272,6 +278,7 @@ { "name": "Patronage", "effect": "Cost of purchasing culture buildings reduced by 50%", + "uniques": ["Cost of purchasing [Culture] buildings reduced by [50]%"] "requires": ["Mercantilism"], "row": 2, "column": 5 @@ -279,13 +286,16 @@ { "name": "Protectionism", "effect": "+1 happiness from each luxury resource", + "uniques": ["+1 happiness from each luxury resource"], "requires": ["Entrepreneurship","Patronage"], "row": 3, "column": 3 }, { "name": "Commerce Complete", - "effect": "+1 gold from every trading post, double gold from Great Merchant trade missions" + "effect": "+1 gold from every trading post, double gold from Great Merchant trade missions", + "uniques": ["[+1 Gold] from every [Trading post]", "Double gold from Great Merchant trade missions"] + "uniques": "+1 } ] }, diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 7acca31e96..c3f1145ba4 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -260,7 +260,7 @@ class CityInfo { for(entry in stats){ if(civInfo.nation.unique == UniqueAbility.INGENUITY) entry.value.science *= 1.5f - if (civInfo.policies.hasEffect("Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange.")) + if (civInfo.hasUnique("Great Merchants are earned 25% faster")) entry.value.gold *= 1.25f if (civInfo.hasUnique("+33% great person generation in all cities")) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 2739128636..567767cd76 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -53,7 +53,7 @@ class CityStats { val civInfo = cityInfo.civInfo var goldFromTradeRoute = civInfo.getCapital().population.population * 0.15 + cityInfo.population.population * 1.1 - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5) if (civInfo.nation.unique == UniqueAbility.TRADE_CARAVANS) goldFromTradeRoute += 1 - if (civInfo.policies.hasEffect("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes")) goldFromTradeRoute += 2 + if (civInfo.hasUnique("+2 Gold from all trade routes")) goldFromTradeRoute += 2 if (civInfo.hasUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality stats.gold += goldFromTradeRoute.toFloat() } @@ -358,7 +358,7 @@ class CityStats { 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()) + if (cityInfo.civInfo.hasUnique("+25% gold in capital") && cityInfo.isCapital()) stats.gold += 25f if (policies.contains("Sovereignty") && cityInfo.civInfo.getHappiness() >= 0) stats.science += 15f diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 2d26ca8da1..7a3554d39a 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -118,7 +118,8 @@ class CivInfoStats(val civInfo: CivilizationInfo){ // TODO - happinessPerUnique should be difficulty-dependent, 5 on Settler and Chieftian and 4 on other difficulties (should be parameter, not in code) var happinessPerUniqueLuxury = 4f + civInfo.getDifficulty().extraHappinessPerLuxury - if (civInfo.policies.hasEffect("+1 happiness from each luxury resource")) happinessPerUniqueLuxury += 1 + for(unique in civInfo.getMatchingUniques("+1 happiness from each luxury resource")) + happinessPerUniqueLuxury += 1 statMap["Luxury resources"]= civInfo.getCivResources().map { it.resource } .count { it.resourceType === ResourceType.Luxury } * happinessPerUniqueLuxury diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index efad09d0ad..ea23a0de84 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -72,8 +72,7 @@ class PolicyManager { if (civInfo.hasUnique("Each city founded increases culture cost of policies 33% less than normal")) cityModifier *= (2 / 3f) - if (isAdopted("Piety Complete")) policyCultureCost *= 0.9 - if (civInfo.hasUnique("Culture cost of adopting new Policies reduced by 10%")) + for(unique in civInfo.getMatchingUniques("Culture cost of adopting new Policies reduced by 10%")) policyCultureCost *= 0.9 if (civInfo.isPlayerCivilization()) policyCultureCost *= civInfo.getDifficulty().policyCostModifier diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 83b650494e..b70d6f58d6 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -249,13 +249,20 @@ open class TileInfo { if (hasViewableResource(observingCiv) && getTileResource().improvement == improvement.name) stats.add(getTileResource().improvementStats!!.clone()) // resource-specific improvement - if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!)) stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines + if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!)) + stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines + + if(city!=null) + for(unique in city.civInfo.getMatchingUniques("[] from every []")) { + val placeholderParams = unique.getPlaceholderParameters() + if (unique == placeholderParams[1]) + stats.add(Stats.parse(placeholderParams[0])) + } + + if (improvement.name == Constants.tradingPost && city != null && city.civInfo.policies.hasEffect("+1 science from every trading post, +17% science from universities")) stats.science += 1f - if (improvement.name == Constants.tradingPost && city != null - && city.civInfo.policies.hasEffect("+1 gold from every trading post, double gold from Great Merchant trade missions")) - stats.gold += 1f if (containsGreatImprovement() && observingCiv.policies.hasEffect("Tile yield from great improvement +100%, golden ages increase by 50%")) stats.add(improvement) // again, for the double effect diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 90ff306164..090c9d6089 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("Entrepreneurship") && hashSetOf("Mint", "Market", "Bank", "Stock Market").contains(baseBuildingName )) - stats.science += 1f - if (adoptedPolicies.contains("Humanism") && hashSetOf("University", "Observatory", "Public School").contains(baseBuildingName )) stats.happiness += 1f @@ -207,11 +204,15 @@ class Building : NamedStats(), IConstruction{ override fun getGoldCost(civInfo: CivilizationInfo): Int { // https://forums.civfanatics.com/threads/rush-buying-formula.393892/ var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100) - if (civInfo.policies.hasEffect("-25% to purchasing items in cities")) cost *= 0.75 - if (civInfo.hasUnique("-15% to purchasing items in cities")) cost *= 0.85 - if (civInfo.policies.hasEffect( "Cost of purchasing culture buildings reduced by 50%") - && culture !=0f && !isWonder) - cost *= 0.5 + + for (unique in civInfo.getMatchingUniques("Cost of purchasing items in cities reduced by []%")) + cost *= 1 - (unique.getPlaceholderParameters()[0].toFloat()) + + for (unique in civInfo.getMatchingUniques("Cost of purchasing [] buildings reduced by []%")) { + val placeholderParams = unique.getPlaceholderParameters() + if (isStatRelated(Stat.valueOf(placeholderParams[0]))) + cost *= 1 - (placeholderParams[1].toFloat() / 100) + } return (cost / 10).toInt() * 10 } diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 28ff1714cb..6599442d09 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -9,6 +9,7 @@ import com.unciv.models.ruleset.Ruleset import com.unciv.models.translations.Translations import com.unciv.models.translations.tr import com.unciv.models.stats.INamed +import com.unciv.models.translations.getPlaceholderParameters // This is BaseUnit because Unit is already a base Kotlin class and to avoid mixing the two up @@ -102,9 +103,9 @@ class BaseUnit : INamed, IConstruction { override fun getGoldCost(civInfo: CivilizationInfo): Int { var cost = getBaseGoldCost() - if (civInfo.policies.adoptedPolicies.contains("Mercantilism")) cost *= 0.75 if (civInfo.policies.adoptedPolicies.contains("Militarism")) cost *= 0.66f - if (civInfo.hasUnique("-15% to purchasing items in cities")) cost *= 0.85 + for(unique in civInfo.getMatchingUniques("Cost of purchasing items in cities reduced by []%")) + cost *= 1-(unique.getPlaceholderParameters()[0].toFloat()) return (cost / 10).toInt() * 10 // rounded down o nearest ten } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 890efa8b40..693b6065af 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -340,7 +340,7 @@ object UnitActions { action = { // http://civilization.wikia.com/wiki/Great_Merchant_(Civ5) var goldEarned = (350 + 50 * unit.civInfo.getEraNumber()) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier - if (unit.civInfo.policies.isAdopted("Commerce Complete")) + if (unit.civInfo.hasUnique("Double gold from Great Merchant trade missions")) goldEarned *= 2 unit.civInfo.gold += goldEarned.toInt() val relevantUnique = unit.getUniques().first { it.startsWith(CAN_UNDERTAKE) }