Resolved #10626 - city-state units work with 'get era' function

This commit is contained in:
Yair Morgenstern 2023-11-30 18:28:17 +02:00
parent 34dce70142
commit d840b4fd4d

View File

@ -51,10 +51,12 @@ class CityStateFunctions(val civInfo: Civilization) {
// Unique unit for militaristic city-states
if (uniqueTypes.contains(UniqueType.CityStateMilitaryUnits)) {
val possibleUnits = ruleset.units.values.filter { it.requiredTechs().any()
&& ruleset.eras[ruleset.technologies[it.requiredTech!!]!!.era()]!!.eraNumber > ruleset.eras[startingEra]!!.eraNumber // Not from the start era or before
&& it.uniqueTo != null && it.uniqueTo in unusedMajorCivs // Must be from a major civ not in the game
&& ruleset.unitTypes[it.unitType]!!.isLandUnit() && ( it.strength > 0 || it.rangedStrength > 0 ) } // Must be a land military unit
val possibleUnits = ruleset.units.values.filter {
val era = it.era(ruleset)
return@filter era != null && era.eraNumber > ruleset.eras[startingEra]!!.eraNumber // Not from the start era or before
&& it.uniqueTo != null && it.uniqueTo in unusedMajorCivs // Must be from a major civ not in the game
&& ruleset.unitTypes[it.unitType]!!.isLandUnit() && (it.strength > 0 || it.rangedStrength > 0) // Must be a land military unit
}
if (possibleUnits.isNotEmpty())
civInfo.cityStateUniqueUnit = possibleUnits.random().name
}