Added 'replacementTextForUniques' parameter to buildings and units for custom text

This commit is contained in:
Yair Morgenstern 2021-01-28 22:05:38 +02:00
parent bcab751f7c
commit 8e8215b5c4
2 changed files with 14 additions and 4 deletions

View File

@ -59,6 +59,7 @@ class Building : NamedStats(), IConstruction {
var quote: String = ""
private var providesFreeBuilding: String? = null
var uniques = ArrayList<String>()
var replacementTextForUniques = ""
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
/**
@ -80,7 +81,10 @@ class Building : NamedStats(), IConstruction {
}
if (requiredNearbyImprovedResources != null)
infoList += ("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr()
if (uniques.isNotEmpty()) infoList += uniques.joinToString { it.tr() }
if (uniques.isNotEmpty()) {
if (replacementTextForUniques != "") infoList += replacementTextForUniques
else infoList += uniques.joinToString { it.tr() }
}
if (cityStrength != 0) infoList += "{City strength} +".tr() + cityStrength
if (cityHealth != 0) infoList += "{City health} +".tr() + cityHealth
if (xpForNewUnits != 0) infoList += "+$xpForNewUnits {XP for new units}".tr()
@ -104,7 +108,10 @@ class Building : NamedStats(), IConstruction {
stringBuilder.appendln("Consumes 1 [$requiredResource]".tr())
if (providesFreeBuilding != null)
stringBuilder.appendln("Provides a free [$providesFreeBuilding] in the city".tr())
if (uniques.isNotEmpty()) stringBuilder.appendln(uniques.asSequence().map { it.tr() }.joinToString("\n"))
if (uniques.isNotEmpty()){
if (replacementTextForUniques != "") stringBuilder.appendln(replacementTextForUniques)
else stringBuilder.appendln(uniques.asSequence().map { it.tr() }.joinToString("\n"))
}
if (!stats.isEmpty())
stringBuilder.appendln(stats)

View File

@ -32,6 +32,7 @@ class BaseUnit : INamed, IConstruction {
var requiredResource: String? = null
var uniques = HashSet<String>()
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
var replacementTextForUniques = ""
var promotions = HashSet<String>()
var obsoleteTech: String? = null
var upgradesTo: String? = null
@ -46,7 +47,8 @@ class BaseUnit : INamed, IConstruction {
if (movement != 2) infoList += "$movement${Fonts.movement}"
for (promotion in promotions)
infoList += promotion.tr()
for (unique in uniques)
if (replacementTextForUniques != "") infoList += replacementTextForUniques
else for (unique in uniques)
infoList += Translations.translateBonusOrPenalty(unique)
return infoList.joinToString()
}
@ -68,7 +70,8 @@ class BaseUnit : INamed, IConstruction {
}
sb.appendln("$movement${Fonts.movement}")
for (unique in uniques)
if (replacementTextForUniques != "") sb.appendln(replacementTextForUniques)
else for (unique in uniques)
sb.appendln(Translations.translateBonusOrPenalty(unique))
if (promotions.isNotEmpty()) {