mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -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."},
|
{"text":"Select an air unit → Select another city within range → Move the unit to the other city."},
|
||||||
],
|
],
|
||||||
"uniques": [
|
"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>"
|
"Unavailable <if tutorial [Move an air unit] is completed>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.unciv.models.ruleset.unique
|
package com.unciv.models.ruleset.unique
|
||||||
|
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
|
import com.unciv.models.translations.equalsPlaceholderText
|
||||||
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
|
|
||||||
object Countables {
|
object Countables {
|
||||||
|
|
||||||
@ -18,22 +20,22 @@ 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
|
||||||
|
|
||||||
|
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 == "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))
|
if (gameInfo.ruleset.tileResources.containsKey(countable))
|
||||||
return stateForConditionals.getResourceAmount(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
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,11 +287,11 @@ 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`
|
- `year`, `turns`
|
||||||
- `Cities`, `Units`, `Air units` - these count your total number
|
- `Cities`, `[cityFilter] Cities`
|
||||||
- Unit name (counts your existing units)
|
- `Units`, `[mapUnitFilter] Units`
|
||||||
- `<unit type> units` (e.g. `Mounted units`) - counts your units by their type (this is not a filter, use the unitType verbatim)
|
- `[buildingFilter] Buildings`
|
||||||
- Building name (counts your existing 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)
|
- 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)
|
- 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