diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index eb0ac9ab8fcae..b8d5030239c02 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -382,7 +382,7 @@ class Ruleset { UniqueValidator(this@Ruleset).checkUnique( Unique(it), false, - cityStateType, + null, true ).isEmpty() }) @@ -390,7 +390,7 @@ class Ruleset { UniqueValidator(this@Ruleset).checkUnique( Unique(it), false, - cityStateType, + null, true ).isEmpty() }) diff --git a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt index 208b7fbb2d7ab..c6788597a3e60 100644 --- a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt @@ -102,7 +102,7 @@ class RulesetValidator(val ruleset: Ruleset) { val errors = uniqueValidator.checkUnique( unique, tryFixUnknownUniques, - cityStateType, + null, true ) lines.addAll(errors) diff --git a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt index f53f1ce6f32fa..649f2a952d98c 100644 --- a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt @@ -9,7 +9,6 @@ import com.unciv.models.ruleset.unique.UniqueComplianceError import com.unciv.models.ruleset.unique.UniqueParameterType import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueType -import com.unciv.models.stats.INamed class UniqueValidator(val ruleset: Ruleset) { @@ -46,7 +45,7 @@ class UniqueValidator(val ruleset: Ruleset) { val errors = checkUnique( unique, tryFixUnknownUniques, - uniqueContainer as? INamed, + uniqueContainer, reportRulesetSpecificErrors ) lines.addAll(errors) @@ -56,16 +55,16 @@ class UniqueValidator(val ruleset: Ruleset) { fun checkUnique( unique: Unique, tryFixUnknownUniques: Boolean, - namedObj: INamed?, + uniqueContainer: IHasUniques?, reportRulesetSpecificErrors: Boolean ): List { - val prefix by lazy { (if (namedObj is IRulesetObject) "${namedObj.originRuleset}: " else "") + - (if (namedObj == null) "The" else "${namedObj.name}'s") } + val prefix by lazy { (if (uniqueContainer is IRulesetObject) "${uniqueContainer.originRuleset}: " else "") + + (if (uniqueContainer == null) "The" else "(${uniqueContainer.getUniqueTarget().name}) ${uniqueContainer.name}'s") } if (unique.type == null) return checkUntypedUnique(unique, tryFixUnknownUniques, prefix) val rulesetErrors = RulesetErrorList() - if (namedObj is IHasUniques && !unique.type.canAcceptUniqueTarget(namedObj.getUniqueTarget())) + if (uniqueContainer != null && !unique.type.canAcceptUniqueTarget(uniqueContainer.getUniqueTarget())) rulesetErrors.add(RulesetError("$prefix unique \"${unique.text}\" is not allowed on its target type", RulesetErrorSeverity.Warning)) val typeComplianceErrors = getComplianceErrors(unique)