Clearer free promotions, nicer Maori Warrior, missing new UnitType translations (#2210)

This commit is contained in:
rh-github-2015
2020-03-21 19:19:50 +01:00
committed by GitHub
parent 8767342810
commit 27c0aedbbd
8 changed files with 48 additions and 6 deletions

View File

@ -71,8 +71,11 @@ class BaseUnit : INamed, IConstruction {
for(unique in uniques)
sb.appendln(Translations.translateBonusOrPenalty(unique))
for(promotion in promotions)
sb.appendln(promotion.tr())
if (promotions.isNotEmpty()) {
sb.append((if (promotions.size==1) "Free promotion:" else "Free promotions:").tr())
for (promotion in promotions)
sb.appendln(" " + promotion.tr())
}
sb.appendln("{Movement}: $movement".tr())
return sb.toString()

View File

@ -1,5 +1,6 @@
package com.unciv.models.ruleset.unit
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.stats.INamed
import com.unciv.models.translations.Translations
import com.unciv.models.translations.tr
@ -10,7 +11,7 @@ class Promotion : INamed{
lateinit var effect:String
var unitTypes = listOf<String>() // The json parser woulddn't agree to deserialize this as a list of UnitTypes. =(
fun getDescription(promotionsForUnitType: Collection<Promotion>, forCivilopedia:Boolean=false):String {
fun getDescription(promotionsForUnitType: Collection<Promotion>, forCivilopedia:Boolean=false, ruleSet:Ruleset? = null):String {
// we translate it before it goes in to get uniques like "vs units in rough terrain" and after to get "vs city
val stringBuilder = StringBuilder()
stringBuilder.appendln(Translations.translateBonusOrPenalty(effect.tr()))
@ -23,8 +24,18 @@ class Promotion : INamed{
stringBuilder.appendln("{Requires}: ".tr()+prerequisitesString.joinToString(" OR ".tr()))
}
if(forCivilopedia){
val unitTypesString = unitTypes.joinToString(", "){it.tr()}
stringBuilder.appendln("Available for [$unitTypesString]".tr())
if (unitTypes.isNotEmpty()) {
val unitTypesString = unitTypes.joinToString(", ") { it.tr() }
stringBuilder.appendln("Available for [$unitTypesString]".tr())
}
if (ruleSet!=null) {
val freeforUnits = ruleSet.units.filter { it.value.promotions.contains(name) }
if (freeforUnits.isNotEmpty()) {
val freeforString = freeforUnits.map { it.value.name }.joinToString(", ") { it.tr() }
stringBuilder.appendln("Free for [$freeforString]".tr())
}
}
}
return stringBuilder.toString()
}

View File

@ -80,7 +80,7 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
ImageGetter.getTechIconGroup(it.name,50f)) }
categoryToEntries["Promotions"] = ruleset.unitPromotions.values
.map { CivilopediaEntry(it.name,it.getDescription(ruleset.unitPromotions.values, true),
.map { CivilopediaEntry(it.name,it.getDescription(ruleset.unitPromotions.values, true, ruleset),
Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) }
categoryToEntries["Tutorials"] = tutorialController.getCivilopediaTutorials()