Problem: Some promotions in CIV 5 have multiple effects, but Unciv promotions only allow for one effect (#3219)

Solution: This PR adds "uniques" field to allow for multiple effects, while keeping "effect" field so that rulesets prior to this PR can still work.
This commit is contained in:
givehub99 2020-10-04 00:55:42 -07:00 committed by GitHub
parent 296da5b205
commit 67efd6c957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -132,7 +132,11 @@ class MapUnit {
val uniques = ArrayList<Unique>()
val baseUnit = baseUnit()
uniques.addAll(baseUnit.uniqueObjects)
uniques.addAll(promotions.promotions.map { currentTile.tileMap.gameInfo.ruleSet.unitPromotions[it]!!.unique })
for (promotion in promotions.promotions) {
uniques.addAll(currentTile.tileMap.gameInfo.ruleSet.unitPromotions[promotion]!!.uniqueObjects)
}
tempUniques = uniques
ignoresTerrainCost = hasUnique("Ignores terrain cost")

View File

@ -9,14 +9,19 @@ import com.unciv.models.translations.tr
class Promotion : INamed{
override lateinit var name: String
var prerequisites = listOf<String>()
var effect=""
val unique:Unique by lazy { Unique(effect) }
var effect = ""
var unitTypes = listOf<String>() // The json parser wouldn't agree to deserialize this as a list of UnitTypes. =(
var uniques = listOf<String>()
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } + Unique(effect) }
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()))
for (unique in uniques + effect) {
stringBuilder.appendln(Translations.translateBonusOrPenalty(unique))
}
if(prerequisites.isNotEmpty()) {
val prerequisitesString: ArrayList<String> = arrayListOf()