diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 8755eab91f..ce7d796623 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -14,7 +14,11 @@ import com.unciv.models.ruleset.unit.Promotion import com.unciv.models.stats.INamed import kotlin.collections.set -class Ruleset() { +class ModOptions { + var techsToRemove = HashSet() +} + +class Ruleset { private val jsonParser = JsonParser() @@ -30,6 +34,7 @@ class Ruleset() { val policyBranches = LinkedHashMap() val difficulties = LinkedHashMap() val mods = LinkedHashSet() + var modOptions = ModOptions() fun clone(): Ruleset { val newRuleset = Ruleset() @@ -46,6 +51,7 @@ class Ruleset() { fun add(ruleset: Ruleset) { buildings.putAll(ruleset.buildings) + for(techToRemove in ruleset.modOptions.techsToRemove) technologies.remove(techToRemove) difficulties.putAll(ruleset.difficulties) nations.putAll(ruleset.nations) policyBranches.putAll(ruleset.policyBranches) @@ -73,9 +79,18 @@ class Ruleset() { mods.clear() } + fun load(folderHandle :FileHandle ) { val gameBasicsStartTime = System.currentTimeMillis() + val modOptionsFile = folderHandle.child("ModOptions.json") + if(modOptionsFile.exists()){ + try { + modOptions = jsonParser.getFromJson(ModOptions::class.java, modOptionsFile) + } + catch (ex:Exception){} + } + val techFile =folderHandle.child("Techs.json") if(techFile.exists()) { val techColumns = jsonParser.getFromJson(Array::class.java, techFile) @@ -168,14 +183,14 @@ object RulesetCache :HashMap() { fun getBaseRuleset() = this[""]!! - fun getComplexRuleset(mods: Collection): Ruleset { + fun getComplexRuleset(mods: LinkedHashSet): Ruleset { val newRuleset = Ruleset() + newRuleset.add(getBaseRuleset()) for (mod in mods) if (containsKey(mod)) { newRuleset.add(this[mod]!!) newRuleset.mods += mod } - newRuleset.add(getBaseRuleset()) return newRuleset } } \ No newline at end of file