Make sure units always have starting promotions. (#6051)

This commit is contained in:
will-ca 2022-01-25 11:51:35 -08:00 committed by GitHub
parent 6a5d44c3e9
commit 88ecbc26b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -130,4 +130,15 @@ object BackwardCompatibility {
civilizations.flatMap { civ -> civ.diplomacy.values }.forEach { it.replaceFlag() }
}
}
/** Make sure all MapUnits have the starting promotions that they're supposed to. */
fun GameInfo.guaranteeUnitPromotions() {
for (tileInfo in tileMap.values) for (unit in tileInfo.getUnits()) {
for (startingPromo in unit.baseUnit.promotions) {
if (startingPromo !in unit.promotions.promotions) {
unit.promotions.addPromotion(startingPromo, true)
}
}
}
}
}

View File

@ -2,6 +2,7 @@ package com.unciv.logic
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.logic.BackwardCompatibility.guaranteeUnitPromotions
import com.unciv.logic.BackwardCompatibility.removeMissingModReferences
import com.unciv.logic.automation.NextTurnAutomation
import com.unciv.logic.civilization.*
@ -452,6 +453,8 @@ class GameInfo {
.flatMap { it.getResourceRequirements().keys } )
barbarians.setTransients(this)
guaranteeUnitPromotions()
}
//endregion