Game can now handle modded unique buildings that don't replace anything existing

This commit is contained in:
Yair Morgenstern
2020-07-28 19:37:30 +03:00
parent 5fbfa637f2
commit f583c04d38
2 changed files with 21 additions and 18 deletions

View File

@ -29,7 +29,7 @@ data class TradeOffer(var name:String, var type: TradeType, var amount:Int=1, va
var offerText = when(type){
TradeType.WarDeclaration -> "Declare war on [$name]"
TradeType.Introduction -> "Introduction to [$name]"
TradeType.City -> UncivGame.Current.gameInfo.getCities().first{ it.id == name }.name
TradeType.City -> UncivGame.Current.gameInfo.getCities().firstOrNull{ it.id == name }?.name ?: "Non-existent city"
else -> name
}.tr()
if (type !in tradesToNotHaveNumbers || name=="Research Agreement") offerText += " ($amount)"

View File

@ -100,6 +100,8 @@ class Nation : INamed {
private fun addUniqueBuildingsText(textList: ArrayList<String>, ruleset: Ruleset) {
for (building in ruleset.buildings.values
.filter { it.uniqueTo == name }) {
if (building.replaces == null) textList += building.getShortDescription(ruleset)
else {
val originalBuilding = ruleset.buildings[building.replaces!!]!!
textList += building.name.tr() + " - " + "Replaces [${originalBuilding.name}]".tr()
@ -121,6 +123,7 @@ class Nation : INamed {
textList += ""
}
}
}
private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) {
for (unit in ruleset.units.values