diff --git a/core/src/com/unciv/GameStarter.kt b/core/src/com/unciv/GameStarter.kt index 7c726e7652..a0ce8abd66 100644 --- a/core/src/com/unciv/GameStarter.kt +++ b/core/src/com/unciv/GameStarter.kt @@ -21,7 +21,7 @@ class GameStarter{ val playerCiv = CivilizationInfo(newGameParameters.nation) - playerCiv.difficulty=newGameParameters.difficulty + gameInfo.difficulty=newGameParameters.difficulty playerCiv.playerType=PlayerType.Human gameInfo.civilizations.add(playerCiv) // first one is player civ @@ -31,7 +31,7 @@ class GameStarter{ for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled() .take(newGameParameters.numberOfEnemies)) { val civ = CivilizationInfo(nationName) - civ.tech.techsResearched.addAll(playerCiv.getDifficulty().aiFreeTechs) + civ.tech.techsResearched.addAll(gameInfo.getDifficulty().aiFreeTechs) gameInfo.civilizations.add(civ) } diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 30928639cc..310bb90b4d 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -15,6 +15,7 @@ class GameInfo { @Deprecated("As of 2.6.9") var tutorial = mutableListOf() var civilizations = mutableListOf() + var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on diffferent difficulties? var tileMap: TileMap = TileMap() var turns = 0 @@ -24,11 +25,13 @@ class GameInfo { toReturn.tileMap = tileMap.clone() toReturn.civilizations.addAll(civilizations.map { it.clone() }) toReturn.turns = turns + toReturn.difficulty=difficulty return toReturn } fun getPlayerCivilization(): CivilizationInfo = civilizations[0] fun getBarbarianCivilization(): CivilizationInfo = civilizations[1] + fun getDifficulty() = GameBasics.Difficulties[difficulty]!! //endregion fun nextTurn() { @@ -98,6 +101,8 @@ class GameInfo { // PlayerType was only added in 2.11.1, so we need to adjust for older saved games if(civilizations.all { it.playerType==PlayerType.AI }) getPlayerCivilization().playerType=PlayerType.Human + if(getPlayerCivilization().difficulty!="Chieftain") + difficulty= getPlayerCivilization().difficulty for (civInfo in civilizations) civInfo.setTransients() diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 38adac4cd9..61be2aad61 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -51,8 +51,8 @@ class CityInfo { } civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) } - if(civInfo == civInfo.gameInfo.getPlayerCivilization()) - civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE) + civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE) + if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding() if (civInfo.cities.size == 1) { cityConstructions.addBuilding("Palace") diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 6dc412fc91..0e03139a10 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -9,6 +9,7 @@ import com.unciv.logic.map.MapUnit import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.models.Counter +import com.unciv.models.gamebasics.Difficulty import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tech.TechEra import com.unciv.models.gamebasics.tile.ResourceType @@ -41,7 +42,7 @@ class CivilizationInfo { var gold = 0 var happiness = 15 - var difficulty = "Chieftain" + @Deprecated("As of 2.11.1") var difficulty = "Chieftain" var playerType = PlayerType.AI var civName = "" var tech = TechManager() @@ -69,7 +70,7 @@ class CivilizationInfo { val toReturn = CivilizationInfo() toReturn.gold = gold toReturn.happiness=happiness - toReturn.difficulty=difficulty + toReturn.playerType=playerType toReturn.civName=civName toReturn.tech = tech.clone() toReturn.policies = policies.clone() @@ -84,7 +85,11 @@ class CivilizationInfo { } //region pure functions - fun getDifficulty() = GameBasics.Difficulties[difficulty]!! + fun getDifficulty():Difficulty { + if(playerType==PlayerType.AI) return GameBasics.Difficulties["Chieftain"]!! + else return gameInfo.getDifficulty() + } + fun getNation() = GameBasics.Nations[civName]!! fun getCapital()=cities.first { it.isCapital() } fun isPlayerCivilization() = gameInfo.getPlayerCivilization()==this diff --git a/core/src/com/unciv/ui/NewGameScreen.kt b/core/src/com/unciv/ui/NewGameScreen.kt index 49c8e6c4c8..4e347623d8 100644 --- a/core/src/com/unciv/ui/NewGameScreen.kt +++ b/core/src/com/unciv/ui/NewGameScreen.kt @@ -157,6 +157,11 @@ class NewGameScreen: PickerScreen(){ newGameOptionsTable.add("{Difficulty}:".tr()) val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, newGameParameters.difficulty, skin) + difficultySelectBox.addListener(object : ChangeListener() { + override fun changed(event: ChangeEvent?, actor: Actor?) { + newGameParameters.difficulty = difficultySelectBox.selected.value + } + }) newGameOptionsTable.add(difficultySelectBox).pad(10f).row() diff --git a/core/src/com/unciv/ui/saves/LoadScreen.kt b/core/src/com/unciv/ui/saves/LoadScreen.kt index 997b977052..468017025e 100644 --- a/core/src/com/unciv/ui/saves/LoadScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadScreen.kt @@ -43,7 +43,8 @@ class LoadScreen : PickerScreen() { textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt) try{ val game = GameSaver().loadGame(it) - textToSet+="\n"+game.getPlayerCivilization()+", {Turn} ".tr()+game.turns + textToSet+="\n"+game.getPlayerCivilization().civName.tr()+ + ", "+game.difficulty.tr()+", {Turn} ".tr()+game.turns }catch (ex:Exception){ textToSet+="\n{Could not load game}!".tr() }