mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 04:43:05 -04:00
Added check for implicit prerequisites that are specified explicitly in mods, to remove clutter in tech trees
This commit is contained in:
parent
93f0b4ae42
commit
5750476cac
@ -318,6 +318,16 @@ class Ruleset {
|
||||
for (prereq in tech.prerequisites) {
|
||||
if (!technologies.containsKey(prereq))
|
||||
lines += "${tech.name} requires tech $prereq which does not exist!"
|
||||
|
||||
fun getPrereqTree(technologyName: String): Sequence<String> {
|
||||
val technology = technologies[technologyName]
|
||||
if (technology == null) return sequenceOf()
|
||||
return technology.prerequisites.asSequence() + technology.prerequisites.flatMap { getPrereqTree(it) }
|
||||
}
|
||||
|
||||
val allOtherPrereqs = tech.prerequisites.asSequence().filterNot { it == prereq }.flatMap { getPrereqTree(it) }
|
||||
if (allOtherPrereqs.contains(prereq))
|
||||
println("No need to add $prereq as a prerequisite of ${tech.name} - it is already implicit from the other prerequisites!")
|
||||
}
|
||||
}
|
||||
return lines.joinToString("\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user