From a3843450bf22ff1031afcad789447f6199762669 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 17 Apr 2020 17:52:45 +0300 Subject: [PATCH] Starting techs no longer hardcoded - this means that mods can have their own tech trees starting wherever --- android/assets/jsons/Techs.json | 4 ++-- core/src/com/unciv/logic/GameStarter.kt | 4 +++- core/src/com/unciv/logic/civilization/CivilizationInfo.kt | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/Techs.json b/android/assets/jsons/Techs.json index 25608e4428..176937967e 100644 --- a/android/assets/jsons/Techs.json +++ b/android/assets/jsons/Techs.json @@ -8,9 +8,9 @@ { "name": "Agriculture", "row": 5, - "quote": "'Where tillage begins, other arts follow. The farmers therefore are the founders of human civilization.' - Daniel Webster" + "quote": "'Where tillage begins, other arts follow. The farmers therefore are the founders of human civilization.' - Daniel Webster", + "uniques": ["Starting tech"] } - ] }, { diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index c6a2d63816..4b252c89b4 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -42,7 +42,7 @@ object GameStarter { civInfo.tech.addTechnology(tech) for (tech in ruleset.technologies.values - .filter { it.era() < newGameParameters.startingEra }) + .filter { ruleset.getEraNumber(it.era()) < ruleset.getEraNumber(newGameParameters.startingEra) }) if (!civInfo.tech.isResearched(tech.name)) civInfo.tech.addTechnology(tech.name) @@ -70,6 +70,8 @@ object GameStarter { else availableCivNames.pop() val playerCiv = CivilizationInfo(nationName) + for(tech in ruleset.technologies.values.filter { it.uniques.contains("Starting tech") }) + playerCiv.tech.techsResearched.add(tech.name) // can't be .addTechnology because the civInfo isn't assigned yet playerCiv.playerType = player.playerType playerCiv.playerId = player.playerId gameInfo.civilizations.add(playerCiv) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 7b0de76d33..832ca8728b 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -83,7 +83,6 @@ class CivilizationInfo { constructor(civName: String) { this.civName = civName - tech.techsResearched.add("Agriculture") // can't be .addTechnology because the civInfo isn't assigned yet } fun clone(): CivilizationInfo {