diff --git a/android/assets/jsons/translationsByLanguage/template.properties b/android/assets/jsons/translationsByLanguage/template.properties index c0cf4f366e..dcc45e96d4 100644 --- a/android/assets/jsons/translationsByLanguage/template.properties +++ b/android/assets/jsons/translationsByLanguage/template.properties @@ -953,6 +953,11 @@ Unhappiness = Victory Types = Workers = +# Other civilopedia things +Nations = +Promotions = +Available for [unitTypes] = + # Policies Adopt policy = diff --git a/android/build.gradle b/android/build.gradle index 9e8fae6030..801d3f62d0 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 29 - versionCode 350 - versionName "3.4.1-patch1" + versionCode 351 + versionName "3.4.2" archivesBaseName = "Unciv" } @@ -169,4 +169,5 @@ idea { } } } - \ No newline at end of file + + diff --git a/core/src/com/unciv/models/ruleset/ICivilopedia.kt b/core/src/com/unciv/models/ruleset/ICivilopedia.kt deleted file mode 100644 index 700ccddd61..0000000000 --- a/core/src/com/unciv/models/ruleset/ICivilopedia.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.unciv.models.ruleset - - -interface ICivilopedia { - val description: String -} diff --git a/core/src/com/unciv/models/ruleset/unit/Promotion.kt b/core/src/com/unciv/models/ruleset/unit/Promotion.kt index 9c01290c4e..e94bc7c5d1 100644 --- a/core/src/com/unciv/models/ruleset/unit/Promotion.kt +++ b/core/src/com/unciv/models/ruleset/unit/Promotion.kt @@ -1,15 +1,31 @@ package com.unciv.models.ruleset.unit -import com.unciv.models.ruleset.ICivilopedia import com.unciv.models.stats.INamed +import com.unciv.models.translations.Translations +import com.unciv.models.translations.tr -class Promotion : ICivilopedia, INamed{ +class Promotion : INamed{ override lateinit var name: String - override val description: String - get(){ - return effect - } var prerequisites = listOf() lateinit var effect:String var unitTypes = listOf() // The json parser woulddn't agree to deserialize this as a list of UnitTypes. =( + + fun getDescription(promotionsForUnitType: Collection, forCivilopedia:Boolean=false):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())) + + if(prerequisites.isNotEmpty()) { + val prerequisitesString:ArrayList = arrayListOf() + for (i in prerequisites.filter { promotionsForUnitType.any { promotion -> promotion.name==it } }){ + prerequisitesString.add(i.tr()) + } + stringBuilder.appendln("{Requires}: ".tr()+prerequisitesString.joinToString(" OR ".tr())) + } + if(forCivilopedia){ + val unitTypesString = unitTypes.joinToString(", "){it.tr()} + stringBuilder.appendln("Available for [$unitTypesString]".tr()) + } + return stringBuilder.toString() + } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/CivilopediaScreen.kt b/core/src/com/unciv/ui/CivilopediaScreen.kt index 54cf2a0e7f..85b4ff11ff 100644 --- a/core/src/com/unciv/ui/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/CivilopediaScreen.kt @@ -79,6 +79,9 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() { categoryToEntries["Technologies"] = ruleset.Technologies.values .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), + Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) } categoryToEntries["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys .filter { !it.startsWith("_") } diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index 858af53718..07b277e9aa 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -8,9 +8,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup import com.badlogic.gdx.utils.Align import com.unciv.UncivGame import com.unciv.logic.map.MapUnit -import com.unciv.models.translations.Translations -import com.unciv.models.translations.tr import com.unciv.models.ruleset.unit.Promotion +import com.unciv.models.translations.tr import com.unciv.ui.utils.* class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() { @@ -61,17 +60,8 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() { rightSideButton.enable() else rightSideButton.disable() - // we translate it before it goes in to get uniques like "vs units in rough terrain" and after to get "vs city - var descriptionText = Translations.translateBonusOrPenalty(promotion.effect.tr()) - if(promotion.prerequisites.isNotEmpty()) { - val prerequisitesString:ArrayList = arrayListOf() - for (i in promotion.prerequisites.filter { promotionsForUnitType.any { promotion -> promotion.name==it } }){ - prerequisitesString.add(i.tr()) - } - descriptionText +="\n{Requires}: ".tr()+prerequisitesString.joinToString(" OR ".tr()) - } - descriptionLabel.setText(descriptionText) + descriptionLabel.setText(promotion.getDescription(promotionsForUnitType)) } val promotionTable = Table()