From 451642450c85f7bdff1d748899b193d76f6a1a3e Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sun, 11 Aug 2024 14:34:03 +0300 Subject: [PATCH] Modding: Added ruleset validation that 2 policies in the same branch do not have the same position --- .../models/ruleset/validation/RulesetValidator.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt index a9c8a2c260..ff6500ff3c 100644 --- a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt @@ -331,13 +331,25 @@ class RulesetValidator(val ruleset: Ruleset) { for (prereq in policy.requires!!) if (!ruleset.policies.containsKey(prereq)) lines.add("${policy.name} requires policy $prereq which does not exist!", sourceObject = policy) + uniqueValidator.checkUniques(policy, lines, true, tryFixUnknownUniques) } - for (branch in ruleset.policyBranches.values) + for (branch in ruleset.policyBranches.values) { if (branch.era !in ruleset.eras) lines.add("${branch.name} requires era ${branch.era} which does not exist!", sourceObject = branch) + val policyLocations = HashMap() + for (policy in branch.policies) { + val policyLocation = "${policy.row}/${policy.column}" + val existingPolicyInLocation = policyLocations[policyLocation] + + if (existingPolicyInLocation == null) policyLocations[policyLocation] = policy + else lines.add("Policies ${policy.name} and ${existingPolicyInLocation.name} in branch ${branch.name}" + + " are both located at column ${policy.column} row ${policy.row}!", sourceObject = policy) + } + } + for (policy in ruleset.policyBranches.values.flatMap { it.policies + it }) if (policy != ruleset.policies[policy.name])