mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Ruleset validation: Catch, and try and fix, unknown json filenames
This commit is contained in:
parent
8527086da9
commit
0d10dae6cd
@ -37,11 +37,14 @@ enum class RulesetFile(val filename: String,
|
||||
Beliefs("Beliefs.json", {beliefs.values.asSequence()}),
|
||||
Buildings("Buildings.json", { buildings.values.asSequence()}),
|
||||
Eras("Eras.json", { eras.values.asSequence() }),
|
||||
Religions("Religions.json"),
|
||||
Nations("Nations.json", { nations.values.asSequence() }),
|
||||
Policies("Policies.json", { policies.values.asSequence() }),
|
||||
Techs("Techs.json", { technologies.values.asSequence() }),
|
||||
Terrains("Terrains.json", { terrains.values.asSequence() }),
|
||||
TileImprovements("TileImprovements.json", { tileImprovements.values.asSequence() }),
|
||||
TileResources("TileResources.json", { tileResources.values.asSequence() }),
|
||||
Specialists("Specialists.json"),
|
||||
Units("Units.json", { units.values.asSequence()}),
|
||||
UnitPromotions("UnitPromotions.json", { unitPromotions.values.asSequence() }),
|
||||
UnitTypes("UnitTypes.json", { unitTypes.values.asSequence() }),
|
||||
|
@ -112,6 +112,22 @@ class RulesetValidator(val ruleset: Ruleset) {
|
||||
if (child.name().endsWith("json") && !child.name().startsWith("Atlas"))
|
||||
lines.add("File ${child.name()} is located in the root folder - it should be moved to a 'jsons' folder")
|
||||
}
|
||||
val jsonFolder = folder.child("jsons")
|
||||
if (jsonFolder.exists()) {
|
||||
for (file in jsonFolder.list("json")) {
|
||||
if (file.name() !in RulesetFile.entries.map { it.filename }) {
|
||||
var text = "File ${file.name()} is in the jsons folder but is not a recognized ruleset file"
|
||||
val similarFilenames = RulesetFile.entries.map { it.filename }.filter {
|
||||
getRelativeTextDistance(
|
||||
it,
|
||||
file.name()
|
||||
) <= RulesetCache.uniqueMisspellingThreshold
|
||||
}
|
||||
if (similarFilenames.isNotEmpty()) text += "\nPossible misspelling of: "+similarFilenames.joinToString("/")
|
||||
lines.add(text, RulesetErrorSeverity.OK)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user