From e83e73310470673b608946cc2d879ed78bd34199 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 21 Nov 2022 23:03:52 +0200 Subject: [PATCH] Added validations for city-state uniques --- .../Civ V - Gods & Kings/CityStateTypes.json | 2 +- .../jsons/Civ V - Vanilla/CityStateTypes.json | 43 ++++-- .../assets/jsons/Civ V - Vanilla/Eras.json | 128 ------------------ .../unciv/models/ruleset/RulesetValidator.kt | 22 ++- .../unciv/models/ruleset/unique/UniqueType.kt | 2 +- 5 files changed, 52 insertions(+), 145 deletions(-) diff --git a/android/assets/jsons/Civ V - Gods & Kings/CityStateTypes.json b/android/assets/jsons/Civ V - Gods & Kings/CityStateTypes.json index 7872557e7e..02bc05cf36 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/CityStateTypes.json +++ b/android/assets/jsons/Civ V - Gods & Kings/CityStateTypes.json @@ -39,7 +39,7 @@ "color": [255, 0, 0] }, { - "name":"Religious", + "name": "Religious", "friendBonusUniques": [ "[+3 Faith] ", "[+6 Faith] ", diff --git a/android/assets/jsons/Civ V - Vanilla/CityStateTypes.json b/android/assets/jsons/Civ V - Vanilla/CityStateTypes.json index 2a4acd4c81..7872557e7e 100644 --- a/android/assets/jsons/Civ V - Vanilla/CityStateTypes.json +++ b/android/assets/jsons/Civ V - Vanilla/CityStateTypes.json @@ -1,32 +1,55 @@ [ { - "name":"Cultured", - "friendBonusUniques": ["[+3 Culture]"], - "allyBonusUniques": ["[+6 Culture]"], + "name": "Cultured", + "friendBonusUniques": [ + "[+3 Culture] ", + "[+6 Culture] ", + "[+13 Culture] " + ], + "allyBonusUniques": [ + "[+6 Culture] ", + "[+12 Culture] ", + "[+26 Culture] " + ], "color": [139, 96, 255] }, { - "name":"Maritime", + "name": "Maritime", "friendBonusUniques": ["[+2 Food] [in capital]"], "allyBonusUniques": ["[+2 Food] [in capital]", "[+1 Food] [in all cities]"], "color": [56, 255, 112] }, { - "name":"Mercantile", - "friendBonusUniques": ["[+2 Happiness]"], - "allyBonusUniques": ["[+2 Happiness]", "Provides a unique luxury"], + "name": "Mercantile", + "friendBonusUniques": [ + "[+2 Happiness] ", + "[+3 Happiness] " + ], + "allyBonusUniques": [ + "[+2 Happiness] ", + "[+3 Happiness] ", + "Provides a unique luxury" + ], "color": [255, 216, 0] }, { - "name":"Militaristic", + "name": "Militaristic", "friendBonusUniques": ["Provides military units every ≈[20] turns"], "allyBonusUniques": ["Provides military units every ≈[17] turns"], "color": [255, 0, 0] }, { "name":"Religious", - "friendBonusUniques": ["[+3 Faith]"], - "allyBonusUniques": ["[+6 Faith]"], + "friendBonusUniques": [ + "[+3 Faith] ", + "[+6 Faith] ", + "[+13 Faith] " + ], + "allyBonusUniques": [ + "[+6 Faith] ", + "[+12 Faith] ", + "[+26 Faith] " + ], "color": [255, 255, 255] } ] diff --git a/android/assets/jsons/Civ V - Vanilla/Eras.json b/android/assets/jsons/Civ V - Vanilla/Eras.json index a730a2ffe8..ad8bf5dcb7 100644 --- a/android/assets/jsons/Civ V - Vanilla/Eras.json +++ b/android/assets/jsons/Civ V - Vanilla/Eras.json @@ -14,20 +14,6 @@ "embarkDefense": 3, "startPercent": 0, "citySound": "cityAncient", - "friendBonus": { - "Cultured": ["Provides [+3 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+2] Happiness"], - "Religious": ["Provides [+3 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+6 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+2] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+6 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [255, 87, 35] }, { @@ -44,20 +30,6 @@ "embarkDefense": 4, "startPercent": 10, "citySound": "cityClassical", - "friendBonus": { - "Cultured": ["Provides [+3 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+2] Happiness"], - "Religious": ["Provides [+3 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+6 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+2] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+6 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [233, 31, 99] }, { @@ -76,20 +48,6 @@ "embarkDefense": 6, "startPercent": 25, "citySound": "cityMedieval", - "friendBonus": { - "Cultured": ["Provides [+6 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+6 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+12 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+12 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [157, 39, 176] }, { @@ -109,20 +67,6 @@ "embarkDefense": 8, "startPercent": 37, "citySound": "cityRenaissance", - "friendBonus": { - "Cultured": ["Provides [+6 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+6 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+12 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+12 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [104, 58, 183] }, { @@ -143,20 +87,6 @@ "embarkDefense": 10, "startPercent": 50, "citySound": "cityIndustrial", - "friendBonus": { - "Cultured": ["Provides [+13 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+13 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+26 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+26 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [63, 81, 182], }, { @@ -178,20 +108,6 @@ "embarkDefense": 13, "startPercent": 65, "citySound": "cityModern", - "friendBonus": { - "Cultured": ["Provides [+13 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+13 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+26 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+26 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [33, 150, 243], }, { @@ -214,20 +130,6 @@ "embarkDefense": 16, "startPercent": 65, "citySound": "cityAtomic", - "friendBonus": { - "Cultured": ["Provides [+13 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+13 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+26 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+26 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - }, "iconRGB": [0, 150, 136], }, { @@ -254,21 +156,6 @@ // But where is the modularity? The excluding of very specific wonders? That is no fun. // So we just write down the entire long list (sorted by era!) instead. "citySound": "cityInformation", - "friendBonus": { - "Cultured": ["Provides [+13 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+13 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+26 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+26 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - - }, "iconRGB": [76, 176, 81], }, { // Technically, this Era doesn't exist in the original game. @@ -294,21 +181,6 @@ "embarkDefense": 25, "startPercent": 80, "citySound": "cityFuture", - "friendBonus": { - "Cultured": ["Provides [+13 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn"], - "Mercantile": ["Provides [+3] Happiness"], - "Religious": ["Provides [+13 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[20] turns"] - }, - "allyBonus": { - "Cultured": ["Provides [+26 Culture] per turn"], - "Maritime": ["Provides [+2 Food] [in capital] per turn", "Provides [+1 Food] [in all cities] per turn"], - "Mercantile": ["Provides [+3] Happiness", "Provides a unique luxury"], - "Religious": ["Provides [+26 Faith] per turn"], - "Militaristic": ["Provides military units every ≈[17] turns"] - - }, "iconRGB": [76, 176, 81], } ] diff --git a/core/src/com/unciv/models/ruleset/RulesetValidator.kt b/core/src/com/unciv/models/ruleset/RulesetValidator.kt index efaa69ce02..85b7ef57c8 100644 --- a/core/src/com/unciv/models/ruleset/RulesetValidator.kt +++ b/core/src/com/unciv/models/ruleset/RulesetValidator.kt @@ -11,7 +11,6 @@ import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.stats.INamed import com.unciv.models.stats.Stats -import com.unciv.models.translations.fillPlaceholders import com.unciv.ui.utils.getRelativeTextDistance class RulesetValidator(val ruleset: Ruleset) { @@ -277,10 +276,10 @@ class RulesetValidator(val ruleset: Ruleset) { if (era.settlerPopulation <= 0) lines += "Population in cities from settlers must be strictly positive! Found value ${era.settlerPopulation} for era ${era.name}" - if (era.allyBonus.isEmpty() && rulesetHasCityStates) - lines.add("No ally bonus defined for era ${era.name}", RulesetErrorSeverity.Warning) - if (era.friendBonus.isEmpty() && rulesetHasCityStates) - lines.add("No friend bonus defined for era ${era.name}", RulesetErrorSeverity.Warning) + if (era.allyBonus.isNotEmpty()) + lines.add("Era ${era.name} contains city-state bonuses. City-state bonuses are now defined in CityStateType.json", RulesetErrorSeverity.WarningOptionsOnly) + if (era.friendBonus.isNotEmpty()) + lines.add("Era ${era.name} contains city-state bonuses. City-state bonuses are now defined in CityStateType.json", RulesetErrorSeverity.WarningOptionsOnly) checkUniques(era, lines, rulesetSpecific, tryFixUnknownUniques) @@ -360,6 +359,19 @@ class RulesetValidator(val ruleset: Ruleset) { lines += "Difficulty ${difficulty.name} contains starting unit $unitName which does not exist!" } + for (cityStateType in ruleset.cityStateTypes.values) { + for (unique in cityStateType.allyBonusUniqueMap.getAllUniques() + cityStateType.friendBonusUniqueMap.getAllUniques()){ + val errors = checkUnique( + unique, + tryFixUnknownUniques, + cityStateType.name, + rulesetSpecific, + UniqueTarget.CityState + ) + lines.addAll(errors) + } + } + @Suppress("DEPRECATION") if (ruleset.modOptions.maxXPfromBarbarians != 30) { lines.add("maxXPfromBarbarians is moved to the constants object, instead use: \nconstants: {\n maxXPfromBarbarians: ${ruleset.modOptions.maxXPfromBarbarians},\n}", RulesetErrorSeverity.Warning) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 851db95bb2..5101151cd8 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -47,7 +47,7 @@ enum class UniqueTarget(val inheritsFrom: UniqueTarget? = null) { // Other Speed, Tutorial, - CityState, + CityState(Global), ModOptions, Conditional, ;