From 4758beffa64e3d303b019cab0e951279a0226404 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 25 Jul 2020 23:03:21 +0300 Subject: [PATCH] More policy conversions --- android/assets/jsons/Civ V - Vanilla/Policies.json | 8 +++++++- core/src/com/unciv/logic/GameInfo.kt | 2 +- core/src/com/unciv/logic/battle/Battle.kt | 2 +- core/src/com/unciv/logic/battle/BattleDamage.kt | 2 +- core/src/com/unciv/logic/city/CityStats.kt | 4 ++-- core/src/com/unciv/logic/civilization/PolicyManager.kt | 8 +++----- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 2 +- core/src/com/unciv/models/ruleset/tile/TileImprovement.kt | 3 ++- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index d9518cfd..6ebb85e4 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -65,12 +65,14 @@ { "name": "Citizenship", "effect": "Tile improvement speed +25%, receive a free worker near the capital", + "uniques": ["Tile improvement speed +25%", "Free [Worker] appears"], "row": 1, "column": 4 }, { "name": "Republic", "effect": "+1 production in every city, +5% production when constructing buildings", + "uniques": ["[+1 Production] in all cities", "+5% production when constructing buildings"], "requires": ["Collective Rule"], "row": 2, "column": 1 @@ -78,6 +80,7 @@ { "name": "Representation", "effect": "Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.", + "uniques": ["Each city founded increases culture cost of policies 33% less than normal", "Empire enters golden age"], "requires": ["Citizenship"], "row": 2, "column": 3 @@ -85,13 +88,15 @@ { "name": "Meritocracy", "effect": "+1 happiness for every city connected to capital, -5% unhappiness from citizens", + "uniques": ["+1 happiness for every city connected to capital", "-5% unhappiness from citizens"], "requires": ["Citizenship"], "row": 2, "column": 5 }, { "name": "Liberty Complete", - "effect": "Free Great Person of choice near capital" + "effect": "Free Great Person of choice near capital", + "uniques": ["Free Great Person"] } ] }, @@ -99,6 +104,7 @@ "name": "Honor", "era": "Ancient era", "effect": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit", + "uniques": ["+25% bonus vs Barbarians", "Gain Culture when you kill a barbarian unit", "Notified of new Barbarian encampments"] "policies": [ { "name": "Warrior Code", diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 3ec3da3e..93eb1c82 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -228,7 +228,7 @@ class GameInfo { * adopted Honor policy and have explored the [tile] where the Barbarian Encampent has spawned. */ fun notifyCivsOfBarbarianEncampment(tile: TileInfo) { - civilizations.filter { it.policies.isAdopted("Honor") + civilizations.filter { it.hasUnique("Notified of new Barbarian encampments") && it.exploredTiles.contains(tile.position) } .forEach { it.addNotification("A new barbarian encampment has spawned!", tile.position, Color.RED) } } diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index d0750b72..daab05b4 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -224,7 +224,7 @@ object Battle { private fun tryGetCultureFromHonor(civUnit:ICombatant, barbarianUnit:ICombatant){ if(barbarianUnit.isDefeated() && barbarianUnit is MapUnitCombatant && barbarianUnit.getCivInfo().isBarbarian() - && civUnit.getCivInfo().policies.isAdopted("Honor")) + && civUnit.getCivInfo().hasUnique("Gain Culture when you kill a barbarian unit")) civUnit.getCivInfo().policies.storedCulture += max(barbarianUnit.unit.baseUnit.strength,barbarianUnit.unit.baseUnit.rangedStrength) } diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 5cb46c5b..3e998da6 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -103,7 +103,7 @@ object BattleDamage { if (enemy.getCivInfo().isBarbarian()) { modifiers["Difficulty"] = civInfo.gameInfo.getDifficulty().barbarianBonus - if (civInfo.policies.hasEffect("+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit")) + if (civInfo.policies.hasEffect("+25% bonus vs Barbarians")) modifiers["vs Barbarians"] = 0.25f } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 1fe72a34..cb387d01 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -199,7 +199,7 @@ class CityStats { unhappinessFromCitizens *= 2f if (civInfo.hasUnique("Unhappiness from population decreased by 10%")) unhappinessFromCitizens *= 0.9f - if (civInfo.policies.hasEffect("+1 happiness for every city connected to capital, -5% unhappiness from citizens")) + if (civInfo.hasUnique("-5% unhappiness from citizens")) unhappinessFromCitizens *= 0.95f if (civInfo.nation.unique == UniqueAbility.POPULATION_GROWTH) unhappinessFromCitizens *= 0.5f //halved for the Indian @@ -212,7 +212,7 @@ class CityStats { if (civInfo.policies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital()) happinessFromPolicies += (cityInfo.population.population / 2).toFloat() - if (civInfo.policies.hasEffect("+1 happiness for every city connected to capital, -5% unhappiness from citizens") + if (civInfo.hasUnique("+1 happiness for every city connected to capital") && cityInfo.isConnectedToCapital()) happinessFromPolicies += 1f if (civInfo.policies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2" diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 4854b591..185b5473 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -70,7 +70,7 @@ class PolicyManager { var policyCultureCost = 25 + (numberOfAdoptedPolicies * 6).toDouble().pow(1.7) var cityModifier = 0.3f * (civInfo.cities.count { !it.isPuppet } - 1) - if (hasEffect("Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.")) + 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%")) @@ -138,13 +138,11 @@ class PolicyManager { if (hasCapital && (unitName != Constants.settler || !civInfo.isOneCityChallenger())) civInfo.placeUnitNearTile(civInfo.getCapital().location, unitName) } - "Tile improvement speed +25%, receive a free worker near the capital" -> - if (hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker) "+1 culture for each monument, temple and monastery. Gain a free policy." -> freePolicies++ - "Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.", + "Empire enters golden age", "+33% culture in all cities with a world wonder, immediately enter a golden age" -> civInfo.goldenAges.enterGoldenAge() - "Free Great Person of choice near capital" -> { + "Free Great Person" -> { if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++ else { val preferredVictoryType = civInfo.victoryType() diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 8b15b15e..b7453e1b 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -275,7 +275,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { // Unit maintenance changed if (unit.canGarrison() && (origin.isCityCenter() || destination.isCityCenter()) - && unit.civInfo.policies.isAdopted("Oligarchy") + && unit.civInfo.hasUnique("Units in cities cost no Maintenance") ) unit.civInfo.updateStatsForNextTurn() // Move through all intermediate tiles to get ancient ruins, barb encampments diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 8a250854..cfb74468 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -27,9 +27,10 @@ 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.policies.isAdopted("Citizenship")) + if (civInfo.hasUnique("Tile improvement speed +25%")) realTurnsToBuild *= 0.75f return realTurnsToBuild.roundToInt() }