mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 11:49:19 +07:00
Added Promotion information to Civilopedia
This commit is contained in:
@ -953,6 +953,11 @@ Unhappiness =
|
||||
Victory Types =
|
||||
Workers =
|
||||
|
||||
# Other civilopedia things
|
||||
Nations =
|
||||
Promotions =
|
||||
Available for [unitTypes] =
|
||||
|
||||
# Policies
|
||||
|
||||
Adopt policy =
|
||||
|
@ -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"
|
||||
}
|
||||
@ -170,3 +170,4 @@ idea {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
package com.unciv.models.ruleset
|
||||
|
||||
|
||||
interface ICivilopedia {
|
||||
val description: String
|
||||
}
|
@ -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<String>()
|
||||
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 {
|
||||
// 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<String> = 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()
|
||||
}
|
||||
}
|
@ -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("_") }
|
||||
|
@ -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<String> = 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()
|
||||
|
Reference in New Issue
Block a user