mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 16:59:11 +07:00
Enabled type check checking for uniques whose deprecation leads to multiple uniques!
This also enables auto-deprecating the Embark+Ocean unique
This commit is contained in:
@ -488,7 +488,7 @@
|
||||
"innerColor": [255,255,78],
|
||||
"favoredReligion": "Christianity",
|
||||
"uniqueName": "Wayfinding",
|
||||
"uniques": ["Can embark and move over Coasts and Oceans immediately", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
|
@ -468,7 +468,7 @@
|
||||
"outerColor": [225,105,0],
|
||||
"innerColor": [255,255,78],
|
||||
"uniqueName": "Wayfinding",
|
||||
"uniques": ["Can embark and move over Coasts and Oceans immediately", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
|
@ -284,7 +284,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// ToDo: make per unit and use unit filters?
|
||||
LandUnitEmbarkation("Enables embarkation for land units", UniqueTarget.Global),
|
||||
EmbarkedUnitsMayEnterOcean("Enables embarked units to enter ocean tiles", UniqueTarget.Global),
|
||||
// todo: Should this be deprecated and replaces with the two above uniques?
|
||||
@Deprecated("as of 3.19.9", ReplaceWith("Enables embarkation for land units <starting from the [Ancient era]>\", \"Enables embarked units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||
EmbarkAndEnterOcean("Can embark and move over Coasts and Oceans immediately", UniqueTarget.Global),
|
||||
|
||||
PopulationLossFromNukes("Population loss from nuclear attacks [amount]% [cityFilter]", UniqueTarget.Global),
|
||||
@ -292,11 +292,14 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
PopulationLossFromNukesDeprecated("Population loss from nuclear attacks -[amount]%", UniqueTarget.Global),
|
||||
|
||||
NaturalReligionSpreadStrength("[amount]% Natural religion spread [cityFilter]", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||
@Deprecated("as of 3.19.3", ReplaceWith("[amount]% Natural religion spread [cityFilter] <after discovering [tech/policy]> OR [amount]% natural religion spread [cityFilter] <after adopting [tech/policy]>"))
|
||||
@Deprecated("as of 3.19.3", ReplaceWith("[amount]% Natural religion spread [cityFilter] <after discovering [tech/policy]>\"" +
|
||||
" OR \"[amount]% Natural religion spread [cityFilter] <after adopting [tech/policy]>"))
|
||||
NaturalReligionSpreadStrengthWith("[amount]% Natural religion spread [cityFilter] with [tech/policy]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
ReligionSpreadDistance("Religion naturally spreads to cities [amount] tiles away", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
|
||||
@Deprecated("as of 3.19.8", ReplaceWith("Only available <before adopting [policy/tech/promotion]> OR <before discovering [policy/tech/promotion]> OR <for units without [policy/tech/promotion]>"))
|
||||
@Deprecated("as of 3.19.8", ReplaceWith("Only available <before adopting [policy/tech/promotion]>" +
|
||||
"\" OR \"Only available <before discovering [policy/tech/promotion]>" +
|
||||
"\" OR \"Only available <for units without [policy/tech/promotion]>"))
|
||||
IncompatibleWith("Incompatible with [policy/tech/promotion]", UniqueTarget.Policy, UniqueTarget.Tech, UniqueTarget.Promotion),
|
||||
StartingTech("Starting tech", UniqueTarget.Tech),
|
||||
StartsWithTech("Starts with [tech]", UniqueTarget.Nation),
|
||||
@ -325,7 +328,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// Meant to be used together with conditionals, like "Only available <after adopting [policy]> <while the empire is happy>"
|
||||
OnlyAvailableWhen("Only available", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Improvement,
|
||||
UniqueTarget.Policy, UniqueTarget.Tech, UniqueTarget.Promotion),
|
||||
@Deprecated("as of 3.19.8", ReplaceWith("Only available <after adopting [buildingName/tech/resource/policy]> OR <with [buildingName/tech/resource/policy]> OR <after discovering [buildingName/tech/resource/policy]>"))
|
||||
@Deprecated("as of 3.19.8", ReplaceWith("Only available <after adopting [buildingName/tech/resource/policy]>\"" +
|
||||
" OR \"Only available <with [buildingName/tech/resource/policy]>\"" +
|
||||
" OR \"Only available <after discovering [buildingName/tech/resource/policy]>"))
|
||||
NotDisplayedWithout("Not displayed as an available construction without [buildingName/tech/resource/policy]", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
ConvertFoodToProductionWhenConstructed("Excess Food converted to Production when under construction", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
RequiresPopulation("Requires at least [amount] population", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
@ -668,7 +673,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// endregion
|
||||
|
||||
// region DEPRECATED AND REMOVED
|
||||
@Deprecated("as of 3.18.14", ReplaceWith("[stats] [in all cities] <before discovering [tech]> OR [stats] [in all cities] <before adopting [policy]>"))
|
||||
@Deprecated("as of 3.18.14", ReplaceWith("[stats] [in all cities] <before discovering [tech]>\" OR \"[stats] [in all cities] <before adopting [policy]>"))
|
||||
StatsFromCitiesBefore("[stats] per turn from cities before [tech/policy]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
|
||||
@Deprecated("as of 3.18.12", ReplaceWith("[amount]% XP gained from combat"), DeprecationLevel.WARNING)
|
||||
@ -776,9 +781,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
StrengthPlus("+[amount]% Strength", UniqueTarget.Unit),
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[-amount]% Strength"), DeprecationLevel.ERROR)
|
||||
StrengthMin("-[amount]% Strength", UniqueTarget.Unit),
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[+amount]% Strength <vs [combatantFilter] units> OR <vs cities>"), DeprecationLevel.ERROR)
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[+amount]% Strength <vs [combatantFilter] units>\" OR \"[+amount]% Strength <vs cities>"), DeprecationLevel.ERROR)
|
||||
StrengthPlusVs("+[amount]% Strength vs [combatantFilter]", UniqueTarget.Unit),
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[-amount]% Strength <vs [combatantFilter] units> OR <vs cities>"), DeprecationLevel.ERROR)
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[-amount]% Strength <vs [combatantFilter] units>\" OR \"[+amount]% Strength <vs cities>"), DeprecationLevel.ERROR)
|
||||
StrengthMinVs("-[amount]% Strength vs [combatantFilter]", UniqueTarget.Unit),
|
||||
@Deprecated("As of 3.17.3 - removed 3.17.13", ReplaceWith("[+amount]% Strength"), DeprecationLevel.ERROR)
|
||||
CombatBonus("+[amount]% Combat Strength", UniqueTarget.Unit),
|
||||
|
@ -381,6 +381,9 @@ Applicable to: Global
|
||||
#### Enables construction of Spaceship parts
|
||||
Applicable to: Global
|
||||
|
||||
#### Notified of new Barbarian encampments
|
||||
Applicable to: Global
|
||||
|
||||
#### Enables Open Borders agreements
|
||||
Applicable to: Global
|
||||
|
||||
@ -503,6 +506,9 @@ Example: "[20]% to Flank Attack bonuses"
|
||||
|
||||
Applicable to: Global, Unit
|
||||
|
||||
#### +30% Strength when fighting City-State units and cities
|
||||
Applicable to: Global
|
||||
|
||||
#### [amount] Movement
|
||||
Example: "[20] Movement"
|
||||
|
||||
@ -1520,13 +1526,14 @@ Applicable to: Conditional
|
||||
- "+[amount]% Defensive Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when defending>"
|
||||
- "[amount]% Attacking Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when attacking>"
|
||||
- "+[amount]% attacking strength for cities with garrisoned units" - Deprecated as of 3.19.1, replace with "[+amount]% Strength for cities <with a garrison> <when attacking>"
|
||||
- "Can embark and move over Coasts and Oceans immediately" - Deprecated as of 3.19.9, replace with "Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>"
|
||||
- "Population loss from nuclear attacks -[amount]%" - Deprecated as of 3.19.2, replace with "Population loss from nuclear attacks [-amount]% [in this city]"
|
||||
- "[amount]% Natural religion spread [cityFilter] with [tech/policy]" - Deprecated as of 3.19.3, replace with "[amount]% Natural religion spread [cityFilter] <after discovering [tech/policy]> OR [amount]% natural religion spread [cityFilter] <after adopting [tech/policy]>"
|
||||
- "[amount]% Natural religion spread [cityFilter] with [tech/policy]" - Deprecated as of 3.19.3, replace with "[amount]% Natural religion spread [cityFilter] <after discovering [tech/policy]>" OR "[amount]% Natural religion spread [cityFilter] <after adopting [tech/policy]>"
|
||||
- "[amount] HP when healing in [tileFilter] tiles" - Deprecated as of 3.19.4, replace with "[amount] HP when healing <in [tileFilter] tiles>"
|
||||
- "Melee units pay no movement cost to pillage" - Deprecated as of 3.18.17, replace with "No movement cost to pillage <for [Melee] units>"
|
||||
- "Heal adjacent units for an additional 15 HP per turn" - Deprecated as of 3.19.3, replace with "All adjacent units heal [+15] HP when healing"
|
||||
- "+[amount]% attack strength to all [mapUnitFilter] units for [amount2] turns" - Deprecated as of 3.19.8, replace with "[+amount]% Strength <when attacking> <for [mapUnitFilter] units> <for [amount2] turns>"
|
||||
- "[stats] per turn from cities before [tech/policy]" - Deprecated as of 3.18.14, replace with "[stats] [in all cities] <before discovering [tech]> OR [stats] [in all cities] <before adopting [policy]>"
|
||||
- "[stats] per turn from cities before [tech/policy]" - Deprecated as of 3.18.14, replace with "[stats] [in all cities] <before discovering [tech]>" OR "[stats] [in all cities] <before adopting [policy]>"
|
||||
- "[mapUnitFilter] units gain [amount]% more Experience from combat" - Deprecated as of 3.18.12, replace with "[amount]% XP gained from combat <for [mapUnitFilter] units>"
|
||||
- "[amount]% maintenance costs for [mapUnitFilter] units" - Deprecated as of 3.18.14, replace with "[amount]% maintenance costs <for [mapUnitFilter] units>"
|
||||
- "50% of excess happiness added to culture towards policies" - Deprecated as of 3.18.2, replace with "[50]% of excess happiness converted to [Culture]"
|
||||
@ -1565,8 +1572,8 @@ Applicable to: Conditional
|
||||
- "-33% unit upkeep costs" - Deprecated Extremely old - used for auto-updates only, replace with "[-33]% maintenance costs <for [All] units>"
|
||||
- "-50% food consumption by specialists" - Deprecated Extremely old - used for auto-updates only, replace with "[-50]% Food consumption by specialists [in all cities]"
|
||||
- "+50% attacking strength for cities with garrisoned units" - Deprecated Extremely old - used for auto-updates only, replace with "[+50]% Strength for cities <with a garrison> <when attacking>"
|
||||
- "Incompatible with [policy/tech/promotion]" - Deprecated as of 3.19.8, replace with "Only available <before adopting [policy/tech/promotion]> OR <before discovering [policy/tech/promotion]> OR <for units without [policy/tech/promotion]>"
|
||||
- "Not displayed as an available construction without [buildingName/tech/resource/policy]" - Deprecated as of 3.19.8, replace with "Only available <after adopting [buildingName/tech/resource/policy]> OR <with [buildingName/tech/resource/policy]> OR <after discovering [buildingName/tech/resource/policy]>"
|
||||
- "Incompatible with [policy/tech/promotion]" - Deprecated as of 3.19.8, replace with "Only available <before adopting [policy/tech/promotion]>" OR "Only available <before discovering [policy/tech/promotion]>" OR "Only available <for units without [policy/tech/promotion]>"
|
||||
- "Not displayed as an available construction without [buildingName/tech/resource/policy]" - Deprecated as of 3.19.8, replace with "Only available <after adopting [buildingName/tech/resource/policy]>" OR "Only available <with [buildingName/tech/resource/policy]>" OR "Only available <after discovering [buildingName/tech/resource/policy]>"
|
||||
- "[stats] with [resource]" - Deprecated as of 3.19.7, replace with "[stats] <with [resource]>"
|
||||
- "Not displayed as an available construction unless [buildingName] is built" - Deprecated as of 3.16.11, replace with "Not displayed as an available construction without [buildingName]"
|
||||
- "[stats] once [tech] is discovered" - Deprecated as of 3.17.10 - removed 3.18.19, replace with "[stats] <after discovering [tech]>"
|
||||
@ -1585,8 +1592,8 @@ Applicable to: Conditional
|
||||
- "Double movement in Snow, Tundra and Hills" - Deprecated As of 3.17.1 - removed 3.17.13, replace with "Double movement in [terrainFilter]"
|
||||
- "+[amount]% Strength" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[+amount]% Strength"
|
||||
- "-[amount]% Strength" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[-amount]% Strength"
|
||||
- "+[amount]% Strength vs [combatantFilter]" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[+amount]% Strength <vs [combatantFilter] units> OR <vs cities>"
|
||||
- "-[amount]% Strength vs [combatantFilter]" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[-amount]% Strength <vs [combatantFilter] units> OR <vs cities>"
|
||||
- "+[amount]% Strength vs [combatantFilter]" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[+amount]% Strength <vs [combatantFilter] units>" OR "[+amount]% Strength <vs cities>"
|
||||
- "-[amount]% Strength vs [combatantFilter]" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[-amount]% Strength <vs [combatantFilter] units>" OR "[+amount]% Strength <vs cities>"
|
||||
- "+[amount]% Combat Strength" - Deprecated As of 3.17.3 - removed 3.17.13, replace with "[+amount]% Strength"
|
||||
- "+1 Visibility Range" - Deprecated Extremely old - used for auto-updates only, replace with "[+1] Sight"
|
||||
- "+[amount] Visibility Range" - Deprecated Extremely old - used for auto-updates only, replace with "[+amount] Sight"
|
||||
|
@ -129,34 +129,40 @@ class BasicTests {
|
||||
var allOK = true
|
||||
for (uniqueType in UniqueType.values()) {
|
||||
val deprecationAnnotation = uniqueType.getDeprecationAnnotation() ?: continue
|
||||
val replacementTextUnique = Unique(deprecationAnnotation.replaceWith.expression)
|
||||
if (replacementTextUnique.type == null && !replacementTextUnique.text.contains(" OR ")) {
|
||||
println("${uniqueType.name}'s deprecation text does not match any existing type!'")
|
||||
allOK = false
|
||||
}
|
||||
if (replacementTextUnique.type == uniqueType){
|
||||
println("${uniqueType.name}'s deprecation text references itself!'")
|
||||
allOK = false
|
||||
}
|
||||
for (conditional in replacementTextUnique.conditionals){
|
||||
if (conditional.type==null){
|
||||
println("${uniqueType.name}'s deprecation text contains conditional \"${conditional.text}\" which does not match any existing type!'")
|
||||
|
||||
val uniquesToCheck = deprecationAnnotation.replaceWith.expression.split("\", \"", "\" OR \"")
|
||||
|
||||
for (uniqueText in uniquesToCheck) {
|
||||
val replacementTextUnique = Unique(uniqueText)
|
||||
|
||||
|
||||
if (replacementTextUnique.type == null) {
|
||||
println("${uniqueType.name}'s deprecation text \"$uniqueText\" does not match any existing type!")
|
||||
allOK = false
|
||||
}
|
||||
}
|
||||
|
||||
var iteration = 1
|
||||
var replacementUnique = Unique(uniqueType.placeholderText)
|
||||
while (replacementUnique.getDeprecationAnnotation() != null) {
|
||||
if (iteration == 10) {
|
||||
if (replacementTextUnique.type == uniqueType) {
|
||||
println("${uniqueType.name}'s deprecation text references itself!")
|
||||
allOK = false
|
||||
println("${uniqueType.name}'s deprecation text never references an undeprecated unique!")
|
||||
break
|
||||
}
|
||||
iteration++
|
||||
replacementUnique = Unique(replacementUnique.getReplacementText())
|
||||
}
|
||||
for (conditional in replacementTextUnique.conditionals) {
|
||||
if (conditional.type == null) {
|
||||
println("${uniqueType.name}'s deprecation text contains conditional \"${conditional.text}\" which does not match any existing type!")
|
||||
allOK = false
|
||||
}
|
||||
}
|
||||
|
||||
var iteration = 1
|
||||
var replacementUnique = Unique(uniqueType.placeholderText)
|
||||
while (replacementUnique.getDeprecationAnnotation() != null) {
|
||||
if (iteration == 10) {
|
||||
allOK = false
|
||||
println("${uniqueType.name}'s deprecation text never references an undeprecated unique!")
|
||||
break
|
||||
}
|
||||
iteration++
|
||||
replacementUnique = Unique(replacementUnique.getReplacementText())
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.assertTrue("This test succeeds only if all deprecated uniques have a replaceWith text that matches an existing type", allOK)
|
||||
}
|
||||
|
Reference in New Issue
Block a user