From a3730a348eb8c984ebd64dd8b34757e80b000c8b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 11 May 2018 16:21:27 +0300 Subject: [PATCH] Turn start/end now work in the correct order - no longer will your units move and immediately be attacked before you can see the attacker! --- core/src/com/unciv/logic/city/CityInfo.kt | 2 +- .../logic/civilization/CivilizationInfo.kt | 18 ++++++++++++++---- .../logic/civilization/GoldenAgeManager.kt | 2 +- .../unciv/logic/civilization/PolicyManager.kt | 2 +- core/src/com/unciv/logic/map/MapUnit.kt | 5 ++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 48f7a292ce..c27f6de092 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -119,7 +119,7 @@ class CityInfo { } - fun nextTurn() { + fun endTurn() { val stats = cityStats.currentCityStats if (cityConstructions.currentConstruction == CityConstructions.Settler && stats.food > 0) { stats.production += stats.food diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 16750f13d1..c414165a6a 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -133,15 +133,15 @@ class CivilizationInfo { newCity.cityConstructions.chooseNextConstruction() } - fun nextTurn() { + fun endTurn() { val nextTurnStats = getStatsForNextTurn() - policies.nextTurn(nextTurnStats.culture.toInt()) + policies.endTurn(nextTurnStats.culture.toInt()) gold += nextTurnStats.gold.toInt() if (cities.size > 0) tech.nextTurn(nextTurnStats.science.toInt()) for (city in cities) { - city.nextTurn() + city.endTurn() greatPeople.addGreatPersonPoints(city.getGreatPersonPoints()) } @@ -150,7 +150,17 @@ class CivilizationInfo { addGreatPerson(greatPerson) } - goldenAges.nextTurn(happiness) + goldenAges.endTurn(happiness) + getCivUnits().forEach { it.endTurn() } + gameInfo.updateTilesToCities() + } + + fun startTurn(){ + getViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better + for (city in cities) + city.cityStats.update() + happiness = getHappinessForNextTurn() + getCivUnits().forEach { it.startTurn() } } fun addGreatPerson(greatPerson: String) { diff --git a/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt b/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt index a092f4125f..6575432402 100644 --- a/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt +++ b/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt @@ -22,7 +22,7 @@ class GoldenAgeManager { civInfo.addNotification("You have entered a golden age!", null) } - fun nextTurn(happiness: Int) { + fun endTurn(happiness: Int) { if (happiness > 0 && !isGoldenAge()) storedHappiness += happiness if (isGoldenAge()) diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 9441d98932..4c5b7fb322 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -78,7 +78,7 @@ class PolicyManager { cityInfo.cityStats.update() } - fun nextTurn(culture: Int) { + fun endTurn(culture: Int) { val couldAdoptPolicyBefore = canAdoptPolicy() storedCulture += culture if (!couldAdoptPolicyBefore && canAdoptPolicy()) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index b2ad6d511a..527c1e7d62 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -90,11 +90,14 @@ class MapUnit { otherTile.unit = this } - fun nextTurn() { + fun endTurn() { doPostTurnAction() if(currentMovement==maxMovement.toFloat()){ // didn't move this turn heal() } + } + + fun startTurn(){ currentMovement = maxMovement.toFloat() doPreTurnAction() }