Resolved #11478 - Made diplomatic modifiers table backwards-compatible

This commit is contained in:
Yair Morgenstern
2024-04-16 00:32:58 +03:00
parent 66656de5fc
commit 31f16abbae
2 changed files with 8 additions and 3 deletions

View File

@ -102,8 +102,12 @@ enum class DiplomaticModifiers(val text: String) {
GaveUsUnits("You gave us units!"),
GaveUsGifts("We appreciate your gifts"),
ReturnedCapturedUnits("You returned captured units to us"),
BelieveSameReligion("We believe in the same religion"),
BelieveSameReligion("We believe in the same religion");
companion object{
private val valuesAsMap = DiplomaticModifiers.values().associateBy { it.name }
fun safeValueOf(name: String) = valuesAsMap[name]
}
}
class DiplomacyManager() : IsPartOfGameInfoSerialization {
@ -113,7 +117,6 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
const val MINIMUM_INFLUENCE = -60f
}
@Suppress("JoinDeclarationAndAssignment") // incorrect warning - constructor would need to be higher in scope
@Transient
lateinit var civInfo: Civilization

View File

@ -199,7 +199,9 @@ class MajorCivDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
&& otherCivDiplomacyManager.hasModifier(DiplomaticModifiers.DestroyedProtectedMinor))
continue
var text = DiplomaticModifiers.valueOf(modifier.key).text.tr() + " "
val diplomaticModifier = DiplomaticModifiers.safeValueOf(modifier.key)
?: continue // This modifier is from the future, you cannot understand it yet
var text = diplomaticModifier.text.tr() + " "
if (modifier.value > 0) text += "+"
text += modifier.value.roundToInt()
val color = if (modifier.value < 0) Color.RED else Color.GREEN