mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 05:51:12 +07:00
Add unit name and building name countables
This commit is contained in:
parent
7474dcaddc
commit
d7018de5c5
@ -10,21 +10,32 @@ object Countables {
|
||||
val relevantStat = Stat.safeValueOf(countable)
|
||||
|
||||
if (relevantStat != null) {
|
||||
return if (stateForConditionals.relevantCity != null) {
|
||||
stateForConditionals.relevantCity!!.getStatReserve(relevantStat)
|
||||
} else if (relevantStat in Stat.statsWithCivWideField && stateForConditionals.relevantCiv != null) {
|
||||
stateForConditionals.relevantCiv!!.getStatReserve(relevantStat)
|
||||
} else {
|
||||
null
|
||||
return when {
|
||||
stateForConditionals.relevantCity != null ->
|
||||
stateForConditionals.relevantCity!!.getStatReserve(relevantStat)
|
||||
relevantStat in Stat.statsWithCivWideField && stateForConditionals.relevantCiv != null ->
|
||||
stateForConditionals.relevantCiv!!.getStatReserve(relevantStat)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
if (stateForConditionals.gameInfo == null) return null
|
||||
val gameInfo = stateForConditionals.gameInfo ?: return null
|
||||
|
||||
if (countable == "year") return stateForConditionals.gameInfo!!.getYear(stateForConditionals.gameInfo!!.turns)
|
||||
if (stateForConditionals.gameInfo!!.ruleset.tileResources.containsKey(countable))
|
||||
if (countable == "year") return stateForConditionals.gameInfo!!.getYear(gameInfo.turns)
|
||||
|
||||
val civInfo = stateForConditionals.relevantCiv ?: return null
|
||||
|
||||
if (gameInfo.ruleset.tileResources.containsKey(countable))
|
||||
return stateForConditionals.getResourceAmount(countable)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -84,9 +84,10 @@ enum class UniqueParameterType(
|
||||
override fun isKnownValue(parameterText: String, ruleset: Ruleset): Boolean {
|
||||
if (parameterText in knownValues) return true
|
||||
if (parameterText.toIntOrNull() != null) return true
|
||||
if (parameterText.toFloatOrNull() != null) return true
|
||||
if (Stat.isStat(parameterText)) return true
|
||||
if (parameterText in ruleset.tileResources) return true
|
||||
if (parameterText in ruleset.units) return true
|
||||
if (parameterText in ruleset.buildings) return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -278,6 +278,21 @@ Used to indicate for what use the terrain should be viewed when dividing the wor
|
||||
Allowed values are:
|
||||
|
||||
- improvement name (Note that "Road" and "Railroad" _do_ work as improvementFilters, but not as tileFilters at the moment.)
|
||||
- "All"
|
||||
- "Great Improvements", "Great"
|
||||
- "All Road" - for Roads & Railroads
|
||||
- `All`
|
||||
- `Great Improvements`, `Great`
|
||||
- `All Road` - for Roads & Railroads
|
||||
|
||||
## countable
|
||||
|
||||
Indicates *something that can be counted*, used both for comparisons and for multiplying uniques
|
||||
|
||||
Allowed values:
|
||||
- `year`
|
||||
- Unit name (counts your existing units)
|
||||
- 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)
|
||||
- Resource name (can be city stats or civilization stats, depending on where the unique is used)
|
||||
|
||||
For example: If a unique is placed on a building, then the retrieved resources will be of the city. If placed on a policy, they will be of the civilization.
|
||||
|
||||
This can make a difference for e.g. local resources, which are counted per city.
|
||||
|
Loading…
Reference in New Issue
Block a user