Game can now handle modded unique buildings that don't replace anything existing
This commit is contained in:
parent
5fbfa637f2
commit
f583c04d38
2 changed files with 21 additions and 18 deletions
|
@ -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)"
|
||||
|
|
|
@ -100,25 +100,28 @@ class Nation : INamed {
|
|||
private fun addUniqueBuildingsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (building in ruleset.buildings.values
|
||||
.filter { it.uniqueTo == name }) {
|
||||
val originalBuilding = ruleset.buildings[building.replaces!!]!!
|
||||
if (building.replaces == null) textList += building.getShortDescription(ruleset)
|
||||
else {
|
||||
val originalBuilding = ruleset.buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - "+"Replaces [${originalBuilding.name}]".tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + "[${stat.value.toInt()}] vs [${originalBuildingStatMap[stat.key]!!.toInt()}]".tr()
|
||||
textList += building.name.tr() + " - " + "Replaces [${originalBuilding.name}]".tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + "[${stat.value.toInt()}] vs [${originalBuildingStatMap[stat.key]!!.toInt()}]".tr()
|
||||
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + "[${building.maintenance}] vs [${originalBuilding.maintenance}]".tr()
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + "[${building.cost}] vs [${originalBuilding.cost}]".tr()
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + "[${building.cityStrength}] vs [${originalBuilding.cityStrength}]".tr()
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + "[${building.cityHealth}] vs [${originalBuilding.cityHealth}]".tr()
|
||||
textList += ""
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + "[${building.maintenance}] vs [${originalBuilding.maintenance}]".tr()
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + "[${building.cost}] vs [${originalBuilding.cost}]".tr()
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + "[${building.cityStrength}] vs [${originalBuilding.cityStrength}]".tr()
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + "[${building.cityHealth}] vs [${originalBuilding.cityHealth}]".tr()
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue