From 827d24c778623b40dfdc9e8e5c65681b12a72662 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 2 May 2019 23:06:34 +0300 Subject: [PATCH] Resolved #694, and another crashing bug --- android/build.gradle | 2 +- .../com/unciv/logic/automation/NextTurnAutomation.kt | 2 +- core/src/com/unciv/logic/city/CityInfo.kt | 5 +++-- .../com/unciv/logic/civilization/CivilizationInfo.kt | 3 ++- core/src/com/unciv/logic/civilization/PopupAlert.kt | 12 +++++++++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index ed4e4367ab..aeddacc770 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,7 +21,7 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 234 + versionCode 236 versionName "2.16.0" } diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 8bb86743dc..63b5d101b5 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -57,7 +57,7 @@ class NextTurnAutomation{ } val otherCivList = civInfo.getKnownCivs() - .filter { it.playerType == PlayerType.AI && !it.isBarbarianCivilization() } + .filter { it.playerType == PlayerType.AI && it.isMajorCiv() } .sortedBy { it.tech.techsResearched.size } for (otherCiv in otherCivList) { diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 074f8b86a5..09d4fe5baa 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -19,6 +19,7 @@ class CityInfo { @Transient var isConnectedToCapital = false @Transient lateinit var ccenterTile:TileInfo // cached for better performance @Transient val range = 2 + @Transient lateinit var tileMap: TileMap var location: Vector2 = Vector2.Zero var name: String = "" @@ -96,8 +97,7 @@ class CityInfo { return toReturn } - internal val tileMap: TileMap - get() = civInfo.gameInfo.tileMap + fun getCenterTile(): TileInfo = ccenterTile fun getTiles(): List = tiles.map { tileMap[it] } @@ -183,6 +183,7 @@ class CityInfo { //region state-changing functions fun setTransients() { + tileMap = civInfo.gameInfo.tileMap ccenterTile = tileMap[location] population.cityInfo = this expansion.cityInfo = this diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 01cfec7e7d..06db40e528 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -98,7 +98,8 @@ class CivilizationInfo { toReturn.goldenAges = goldenAges.clone() toReturn.greatPeople = greatPeople.clone() toReturn.victoryManager = victoryManager.clone() - toReturn.diplomacy.putAll(diplomacy) + for(diplomacyManager in diplomacy.values.map { it.clone() }) + toReturn.diplomacy.put(diplomacyManager.otherCivName, diplomacyManager) toReturn.cities = cities.map { it.clone() } toReturn.exploredTiles.addAll(exploredTiles) toReturn.notifications.addAll(notifications) diff --git a/core/src/com/unciv/logic/civilization/PopupAlert.kt b/core/src/com/unciv/logic/civilization/PopupAlert.kt index 8ca8f8d797..377547cf3c 100644 --- a/core/src/com/unciv/logic/civilization/PopupAlert.kt +++ b/core/src/com/unciv/logic/civilization/PopupAlert.kt @@ -7,4 +7,14 @@ enum class AlertType{ CityConquered } -class PopupAlert (val type:AlertType, val value:String) +class PopupAlert { + lateinit var type: AlertType + lateinit var value: String + + constructor(type: AlertType, value: String) { + this.type = type + this.value = value + } + + constructor() // for json serialization +}