Better countables - phase 1

This commit is contained in:
yairm210 2024-06-25 23:43:11 +03:00
parent f7f5ab78d3
commit 7165c62573
4 changed files with 15 additions and 12 deletions

View File

@ -8,7 +8,7 @@
{"text":"Click on a unit → Click on a destination → Click the arrow popup."}, {"text":"Click on a unit → Click on a destination → Click the arrow popup."},
], ],
"uniques": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Units] is greater than [0]>", "Only available <if tutorials are enabled> <when number of [units] is greater than [0]>",
"Unavailable <if tutorial [Move unit] is completed>" "Unavailable <if tutorial [Move unit] is completed>"
] ]
}, },
@ -34,7 +34,7 @@
{"text":"Click the city button twice."}, {"text":"Click the city button twice."},
], ],
"uniques": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Cities] is greater than [0]>", "Only available <if tutorials are enabled> <when number of [cities] is greater than [0]>",
"Unavailable <if tutorial [Enter city screen] is completed>" "Unavailable <if tutorial [Enter city screen] is completed>"
] ]
}, },
@ -60,7 +60,7 @@
{"text":"Enter city screen → Click on a unit or building → Click 'add to queue'."}, {"text":"Enter city screen → Click on a unit or building → Click 'add to queue'."},
], ],
"uniques": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Cities] is greater than [0]>", "Only available <if tutorials are enabled> <when number of [cities] is greater than [0]>",
"Unavailable <if tutorial [Pick construction] is completed>" "Unavailable <if tutorial [Pick construction] is completed>"
] ]
}, },
@ -86,7 +86,7 @@
{"text":"Enter city screen → Click the assigned tile to unassign → Click an unassigned tile to assign population."}, {"text":"Enter city screen → Click the assigned tile to unassign → Click an unassigned tile to assign population."},
], ],
"uniques": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Cities] is greater than [0]>", "Only available <if tutorials are enabled> <when number of [cities] is greater than [0]>",
"Unavailable <if tutorial [Reassign worked tiles] is completed>" "Unavailable <if tutorial [Reassign worked tiles] is completed>"
] ]
}, },
@ -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."}, {"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": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Cities] is greater than [0]>", "Only available <if tutorials are enabled> <when number of [cities] is greater than [0]>",
"Unavailable <if tutorial [Construct an improvement] is completed>" "Unavailable <if tutorial [Construct an improvement] is completed>"
] ]
}, },
@ -144,7 +144,7 @@
{"text":"Construct roads between your capital and another city. Or, automate your worker and let him get to that eventually."}, {"text":"Construct roads between your capital and another city. Or, automate your worker and let him get to that eventually."},
], ],
"uniques": [ "uniques": [
"Only available <if tutorials are enabled> <when number of [Cities] is greater than [1]>", "Only available <if tutorials are enabled> <when number of [cities] is greater than [1]>",
"Unavailable <if tutorial [Create a trade route] is completed>" "Unavailable <if tutorial [Create a trade route] is completed>"
] ]
}, },

View File

@ -17,8 +17,8 @@ object Countables {
val civInfo = stateForConditionals.relevantCiv ?: return null val civInfo = stateForConditionals.relevantCiv ?: return null
if (countable == "Cities") return civInfo.cities.size if (countable == "cities") return civInfo.cities.size
if (countable == "Units") return civInfo.units.getCivUnitsSize() if (countable == "units") return civInfo.units.getCivUnitsSize()
if (countable == "Air units") return civInfo.units.getCivUnits().count { it.baseUnit.movesLikeAirUnits() } if (countable == "Air units") return civInfo.units.getCivUnits().count { it.baseUnit.movesLikeAirUnits() }
if (gameInfo.ruleset.tileResources.containsKey(countable)) if (gameInfo.ruleset.tileResources.containsKey(countable))

View File

@ -65,7 +65,7 @@ enum class UniqueParameterType(
Countable("countable", "1000", "This indicates a number or a numeric variable") { Countable("countable", "1000", "This indicates a number or a numeric variable") {
// todo add more countables // todo add more countables
private val knownValues = setOf( private val knownValues = setOf(
"year", "turns", "Cities", "Units" "year", "turns", "cities", "units"
) )
override fun isKnownValue(parameterText: String, ruleset: Ruleset) = when { override fun isKnownValue(parameterText: String, ruleset: Ruleset) = when {
@ -75,7 +75,8 @@ enum class UniqueParameterType(
parameterText in ruleset.tileResources -> true parameterText in ruleset.tileResources -> true
parameterText in ruleset.units -> true parameterText in ruleset.units -> true
parameterText.removeSuffix(" units").removeSurrounding("[", "]") in ruleset.unitTypes -> true parameterText.removeSuffix(" units").removeSurrounding("[", "]") in ruleset.unitTypes -> true
else -> parameterText in ruleset.buildings parameterText in ruleset.buildings -> true
else -> false
} }
}, },

View File

@ -287,8 +287,10 @@ Allowed values are:
Indicates *something that can be counted*, used both for comparisons and for multiplying uniques Indicates *something that can be counted*, used both for comparisons and for multiplying uniques
Allowed values: 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) - Unit name (counts your existing units)
- `<unit type> units` (e.g. `Mounted units`) - counts your units by their type (this is not a filter, use the unitType verbatim) - `<unit type> 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) - Building name (counts your existing buildings)