Autoupdates to uniques will multiple solutions now replace to the correct one (#6208)

* Autoupdates to uniques will multiple solutions now replace to the correct one

Problem - some deprecated uniques can lead to multiple possibilities of replacements, depending on the parameter type
This lead to replacements in the jsons that were either unparseable entirely or were causing errors, both of which needed to be corrected by hand
We now separate such deprecations into their constituent potential replacement uniques, and try and take only the unique that doesn't cause any errors
Works like a charmander :)

* Conditional name change

* Resolved #6179 - when changing units production due to deprecation, notification no longer counts the same city multiple times if it appears multiple times in its queue
This commit is contained in:
Yair Morgenstern
2022-02-22 11:33:07 +02:00
committed by GitHub
parent d30ea86b27
commit 13af71e427
8 changed files with 76 additions and 19 deletions

View File

@ -2,6 +2,7 @@
package com.unciv.testing
import com.badlogic.gdx.Gdx
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.UncivGameParameters
import com.unciv.models.metadata.BaseRuleset
@ -130,7 +131,7 @@ class BasicTests {
for (uniqueType in UniqueType.values()) {
val deprecationAnnotation = uniqueType.getDeprecationAnnotation() ?: continue
val uniquesToCheck = deprecationAnnotation.replaceWith.expression.split("\", \"", "\" OR \"")
val uniquesToCheck = deprecationAnnotation.replaceWith.expression.split("\", \"", Constants.uniqueOrDelimiter)
for (uniqueText in uniquesToCheck) {
val replacementTextUnique = Unique(uniqueText)
@ -160,7 +161,7 @@ class BasicTests {
break
}
iteration++
replacementUnique = Unique(replacementUnique.getReplacementText())
replacementUnique = Unique(replacementUnique.getReplacementText(ruleset))
}
}
}