Skip to content

Commit

Permalink
Added "Remaining [civFilter] Civilizations" as countable value
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Oct 10, 2024
1 parent be40912 commit 2e51de3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 2 additions & 6 deletions android/assets/jsons/translations/template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1968,13 +1968,9 @@ Cannot be built on [tileFilter] tiles =
Does not need removal of [feature] =
Gain a free [building] [cityFilter] =
# Uniques not found in JSON files
# Countables
Only available after [] turns =
This Unit upgrades for free =
[stats] when a city adopts this religion for the first time =
Never destroyed when the city is captured =
Invisible to others =
Remaining [civFilter] Civilizations =
# Unused Resources
Expand Down
4 changes: 4 additions & 0 deletions core/src/com/unciv/models/ruleset/unique/Countables.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ object Countables {
if (countable.equalsPlaceholderText("[] Buildings"))
return civInfo.cities.sumOf { it.cityConstructions.getBuiltBuildings()
.count { it.matchesFilter(placeholderParameters[0]) } }

if (countable.equalsPlaceholderText("Remaining [] Civilizations"))
return gameInfo.civilizations.filter { !it.isDefeated() }
.count { it.matchesFilter(placeholderParameters[0]) }

if (gameInfo.ruleset.tileResources.containsKey(countable))
return stateForConditionals.getResourceAmount(countable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.unciv.models.ruleset.unique.UniqueParameterType.Companion.guessTypeFo
import com.unciv.models.ruleset.validation.Suppression
import com.unciv.models.stats.Stat
import com.unciv.models.translations.TranslationFileWriter
import com.unciv.models.translations.equalsPlaceholderText

// 'region' names beginning with an underscore are used here for a prettier "Structure window" - they go in front of the rest.

Expand Down Expand Up @@ -71,6 +72,10 @@ enum class UniqueParameterType(

override fun isKnownValue(parameterText: String, ruleset: Ruleset) = when {
parameterText.toIntOrNull() != null -> true
parameterText.equalsPlaceholderText("[] Buildings") -> true
parameterText.equalsPlaceholderText("[] Cities") -> true
parameterText.equalsPlaceholderText("[] Units") -> true
parameterText.equalsPlaceholderText("Remaining [] Civilizations") -> true
else -> super.isKnownValue(parameterText, ruleset)
}

Expand Down

0 comments on commit 2e51de3

Please sign in to comment.