Resolved #9740 - incorrect ruleset combos for 'buy building with stat' no longer crash

This commit is contained in:
Yair Morgenstern 2023-07-05 21:59:01 +03:00
parent 103234a6b8
commit fdb07b06c1
2 changed files with 7 additions and 2 deletions

View File

@ -492,7 +492,12 @@ class Civilization : IsPartOfGameInfoSerialization {
return tech.currentTechnology() == null && cities.isNotEmpty()
}
fun getEquivalentBuilding(buildingName: String) = getEquivalentBuilding(gameInfo.ruleset.buildings[buildingName]!!)
fun getEquivalentBuilding(buildingName: String): Building {
val building = gameInfo.ruleset.buildings[buildingName]
?: throw Exception("No building by the name of $buildingName exists!")
return getEquivalentBuilding(building)
}
fun getEquivalentBuilding(baseBuilding: Building): Building {
if (baseBuilding.replaces != null)
return getEquivalentBuilding(baseBuilding.replaces!!)

View File

@ -108,6 +108,6 @@ class Religion() : INamed, IsPartOfGameInfoSerialization {
belief.getMatchingUniques(UniqueType.BuyBuildingsWithStat).map { it.params[0] } +
belief.getMatchingUniques(UniqueType.BuyBuildingsForAmountStat).map { it.params[0] } +
belief.getMatchingUniques(UniqueType.BuyBuildingsIncreasingCost).map { it.params[0] }
}.toList()
}.filter { gameInfo.ruleset.buildings.containsKey(it) }.toList()
}
}