From d840b4fd4df0d733351e2f08aabca88517bc01be Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 30 Nov 2023 18:28:17 +0200 Subject: [PATCH] Resolved #10626 - city-state units work with 'get era' function --- .../logic/civilization/diplomacy/CityStateFunctions.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt index 0b520cd75d..96d185b09c 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt @@ -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 }