mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Countables for Cities, Units, Buildings allow filters
This commit is contained in:
parent
d640ed9557
commit
095c4faed6
@ -170,7 +170,7 @@
|
||||
{"text":"Select an air unit → Select another city within range → Move the unit to the other city."},
|
||||
],
|
||||
"uniques": [
|
||||
"Only available <if tutorials are enabled> <when number of [Air units] is greater than [0]>",
|
||||
"Only available <if tutorials are enabled> <when number of [[Air] Units] is greater than [0]>",
|
||||
"Unavailable <if tutorial [Move an air unit] is completed>"
|
||||
]
|
||||
},
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.unciv.models.ruleset.unique
|
||||
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.translations.equalsPlaceholderText
|
||||
import com.unciv.models.translations.getPlaceholderParameters
|
||||
|
||||
object Countables {
|
||||
|
||||
@ -18,22 +20,22 @@ object Countables {
|
||||
val civInfo = stateForConditionals.relevantCiv ?: return null
|
||||
|
||||
if (countable == "Cities") return civInfo.cities.size
|
||||
|
||||
val placeholderParameters = countable.getPlaceholderParameters()
|
||||
if (countable.equalsPlaceholderText("[] Cities"))
|
||||
return civInfo.cities.count { it.matchesFilter(placeholderParameters[0]) }
|
||||
|
||||
if (countable == "Units") return civInfo.units.getCivUnitsSize()
|
||||
if (countable == "Air units") return civInfo.units.getCivUnits().count { it.baseUnit.movesLikeAirUnits() }
|
||||
if (countable.equalsPlaceholderText("[] Units"))
|
||||
return civInfo.units.getCivUnits().count { it.matchesFilter(placeholderParameters[0]) }
|
||||
|
||||
if (countable.equalsPlaceholderText("[] Buildings"))
|
||||
return civInfo.cities.sumOf { it.cityConstructions.getBuiltBuildings()
|
||||
.count { it.matchesFilter(placeholderParameters[0]) } }
|
||||
|
||||
if (gameInfo.ruleset.tileResources.containsKey(countable))
|
||||
return stateForConditionals.getResourceAmount(countable)
|
||||
|
||||
val unitTypeName = countable.removeSuffix(" units").removeSurrounding("[", "]")
|
||||
if (unitTypeName in gameInfo.ruleset.unitTypes)
|
||||
return civInfo.units.getCivUnits().count { it.type.name == unitTypeName }
|
||||
|
||||
if (countable in gameInfo.ruleset.units)
|
||||
return civInfo.units.getCivUnits().count { it.name == countable }
|
||||
|
||||
if (countable in gameInfo.ruleset.buildings)
|
||||
return civInfo.cities.count { it.cityConstructions.containsBuildingOrEquivalent(countable) }
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -287,11 +287,11 @@ 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
|
||||
- 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)
|
||||
- Building name (counts your existing buildings)
|
||||
- `Cities`, `[cityFilter] Cities`
|
||||
- `Units`, `[mapUnitFilter] Units`
|
||||
- `[buildingFilter] Buildings`
|
||||
- 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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user