Rename BaseUnit.techsAtWhichNoLongerAvailable() (#10663)

* Update BaseUnit.kt

* Update BaseUnit.kt

* Update RulesetValidator.kt

* Update BaseUnit.kt
This commit is contained in:
dHannasch 2023-12-04 11:26:15 -07:00 committed by GitHub
parent ca20a09a99
commit 8a03f9df12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -49,6 +49,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
var promotions = HashSet<String>()
var obsoleteTech: String? = null
fun techsThatObsoleteThis(): Sequence<String> = if (obsoleteTech == null) sequenceOf() else sequenceOf(obsoleteTech!!)
fun techsAtWhichNoLongerAvailable(): Sequence<String> = techsThatObsoleteThis()
fun isObsoletedBy(techName: String): Boolean = techsThatObsoleteThis().contains(techName)
var upgradesTo: String? = null
var replaces: String? = null
@ -161,7 +162,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
for (requiredTech: String in requiredTechs())
if (!civ.tech.isResearched(requiredTech))
yield(RejectionReasonType.RequiresTech.toInstance("$requiredTech not researched"))
for (obsoleteTech: String in techsThatObsoleteThis())
for (obsoleteTech: String in techsAtWhichNoLongerAvailable())
if (civ.tech.isResearched(obsoleteTech))
yield(RejectionReasonType.Obsoleted.toInstance("Obsolete by $obsoleteTech"))

View File

@ -658,7 +658,7 @@ class RulesetValidator(val ruleset: Ruleset) {
for (requiredTech: String in unit.requiredTechs())
if (!ruleset.technologies.containsKey(requiredTech))
lines += "${unit.name} requires tech ${requiredTech} which does not exist!"
for (obsoleteTech: String in unit.techsThatObsoleteThis())
for (obsoleteTech: String in unit.techsAtWhichNoLongerAvailable())
if (!ruleset.technologies.containsKey(obsoleteTech))
lines += "${unit.name} obsoletes at tech ${obsoleteTech} which does not exist!"
if (unit.upgradesTo != null && !ruleset.units.containsKey(unit.upgradesTo!!))