From 7165c6257356adf3246e27680564f7a6dd48ae00 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 25 Jun 2024 23:43:11 +0300 Subject: [PATCH] Better countables - phase 1 --- .../assets/jsons/Civ V - Gods & Kings/Events.json | 12 ++++++------ .../com/unciv/models/ruleset/unique/Countables.kt | 4 ++-- .../models/ruleset/unique/UniqueParameterType.kt | 5 +++-- docs/Modders/Unique-parameters.md | 6 ++++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/android/assets/jsons/Civ V - Gods & Kings/Events.json b/android/assets/jsons/Civ V - Gods & Kings/Events.json index 3a23e19b0c..6523765ff8 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Events.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Events.json @@ -8,7 +8,7 @@ {"text":"Click on a unit → Click on a destination → Click the arrow popup."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, @@ -34,7 +34,7 @@ {"text":"Click the city button twice."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, @@ -60,7 +60,7 @@ {"text":"Enter city screen → Click on a unit or building → Click 'add to queue'."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, @@ -86,7 +86,7 @@ {"text":"Enter city screen → Click the assigned tile to unassign → Click an unassigned tile to assign population."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, @@ -131,7 +131,7 @@ {"text":"Construct a Worker unit → Move it to a Plains or Grassland tile → Click 'Construct improvement' → Choose the farm → Leave the worker there until it's finished."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, @@ -144,7 +144,7 @@ {"text":"Construct roads between your capital and another city. Or, automate your worker and let him get to that eventually."}, ], "uniques": [ - "Only available ", + "Only available ", "Unavailable " ] }, diff --git a/core/src/com/unciv/models/ruleset/unique/Countables.kt b/core/src/com/unciv/models/ruleset/unique/Countables.kt index 7440239c31..696b62ca44 100644 --- a/core/src/com/unciv/models/ruleset/unique/Countables.kt +++ b/core/src/com/unciv/models/ruleset/unique/Countables.kt @@ -17,8 +17,8 @@ object Countables { val civInfo = stateForConditionals.relevantCiv ?: return null - if (countable == "Cities") return civInfo.cities.size - if (countable == "Units") return civInfo.units.getCivUnitsSize() + if (countable == "cities") return civInfo.cities.size + if (countable == "units") return civInfo.units.getCivUnitsSize() if (countable == "Air units") return civInfo.units.getCivUnits().count { it.baseUnit.movesLikeAirUnits() } if (gameInfo.ruleset.tileResources.containsKey(countable)) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt index 9594dd1e7c..b8af036d2c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt @@ -65,7 +65,7 @@ enum class UniqueParameterType( Countable("countable", "1000", "This indicates a number or a numeric variable") { // todo add more countables private val knownValues = setOf( - "year", "turns", "Cities", "Units" + "year", "turns", "cities", "units" ) override fun isKnownValue(parameterText: String, ruleset: Ruleset) = when { @@ -75,7 +75,8 @@ enum class UniqueParameterType( parameterText in ruleset.tileResources -> true parameterText in ruleset.units -> true parameterText.removeSuffix(" units").removeSurrounding("[", "]") in ruleset.unitTypes -> true - else -> parameterText in ruleset.buildings + parameterText in ruleset.buildings -> true + else -> false } }, diff --git a/docs/Modders/Unique-parameters.md b/docs/Modders/Unique-parameters.md index df2d04479f..d9a1ce4db3 100644 --- a/docs/Modders/Unique-parameters.md +++ b/docs/Modders/Unique-parameters.md @@ -287,8 +287,10 @@ Allowed values are: Indicates *something that can be counted*, used both for comparisons and for multiplying uniques Allowed values: -- `year`, `turns` -- `Cities`, `Units`, `Air units` - these count your total number + +- `year` +- `turns` +- `cities`, `units`, `Air units` - these count your total number - Unit name (counts your existing units) - ` units` (e.g. `Mounted units`) - counts your units by their type (this is not a filter, use the unitType verbatim) - Building name (counts your existing buildings)