From bdcc0bb0d62b1fba9b6db6539509619f11764659 Mon Sep 17 00:00:00 2001 From: PLynx Date: Sun, 10 Nov 2024 13:25:48 +0100 Subject: [PATCH] Add owned tiles countable (#12423) * Added owned tiles countable * Applied yairm210's suggestions * Added template.properties key --- android/assets/jsons/translations/template.properties | 1 + core/src/com/unciv/models/ruleset/unique/Countables.kt | 3 +++ .../src/com/unciv/models/ruleset/unique/UniqueParameterType.kt | 1 + docs/Modders/Unique-parameters.md | 1 + 4 files changed, 6 insertions(+) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index e8ab7ee79b..ce350b4d35 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1973,6 +1973,7 @@ Gain a free [building] [cityFilter] = # Countables Remaining [civFilter] Civilizations = +Owned [tileFilter] Tiles = # Unused Resources diff --git a/core/src/com/unciv/models/ruleset/unique/Countables.kt b/core/src/com/unciv/models/ruleset/unique/Countables.kt index 0f83942639..bbb844bfea 100644 --- a/core/src/com/unciv/models/ruleset/unique/Countables.kt +++ b/core/src/com/unciv/models/ruleset/unique/Countables.kt @@ -36,6 +36,9 @@ object Countables { if (countable.equalsPlaceholderText("Remaining [] Civilizations")) return gameInfo.civilizations.filter { !it.isDefeated() } .count { it.matchesFilter(placeholderParameters[0]) } + + if (countable.equalsPlaceholderText("Owned [] Tiles")) + return civInfo.cities.sumOf { it.getTiles().count { it.matchesFilter(placeholderParameters[0]) } } if (gameInfo.ruleset.tileResources.containsKey(countable)) return stateForConditionals.getResourceAmount(countable) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt index 21dd9d23ae..76ccfe5e40 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt @@ -76,6 +76,7 @@ enum class UniqueParameterType( parameterText.equalsPlaceholderText("[] Cities") -> true parameterText.equalsPlaceholderText("[] Units") -> true parameterText.equalsPlaceholderText("Remaining [] Civilizations") -> true + parameterText.equalsPlaceholderText("Owned [] Tiles") -> true else -> super.isKnownValue(parameterText, ruleset) } diff --git a/docs/Modders/Unique-parameters.md b/docs/Modders/Unique-parameters.md index 4119d18e92..b4d379c34a 100644 --- a/docs/Modders/Unique-parameters.md +++ b/docs/Modders/Unique-parameters.md @@ -313,6 +313,7 @@ Allowed values: - `Units`, `[mapUnitFilter] Units` - `[buildingFilter] Buildings` - `Remaining [civFilter] Civilizations` +- `[tileFilter] Tiles` - Stat name - gets the stat *reserve*, not the amount per turn (can be city stats or civilization stats, depending on where the unique is used) - Resource name (can be city stats or civilization stats, depending on where the unique is used)