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!

This commit is contained in:
Yair Morgenstern 2018-05-11 16:21:27 +03:00
parent a4fcc3a694
commit a3730a348e
5 changed files with 21 additions and 8 deletions

View File

@ -119,7 +119,7 @@ class CityInfo {
} }
fun nextTurn() { fun endTurn() {
val stats = cityStats.currentCityStats val stats = cityStats.currentCityStats
if (cityConstructions.currentConstruction == CityConstructions.Settler && stats.food > 0) { if (cityConstructions.currentConstruction == CityConstructions.Settler && stats.food > 0) {
stats.production += stats.food stats.production += stats.food

View File

@ -133,15 +133,15 @@ class CivilizationInfo {
newCity.cityConstructions.chooseNextConstruction() newCity.cityConstructions.chooseNextConstruction()
} }
fun nextTurn() { fun endTurn() {
val nextTurnStats = getStatsForNextTurn() val nextTurnStats = getStatsForNextTurn()
policies.nextTurn(nextTurnStats.culture.toInt()) policies.endTurn(nextTurnStats.culture.toInt())
gold += nextTurnStats.gold.toInt() gold += nextTurnStats.gold.toInt()
if (cities.size > 0) tech.nextTurn(nextTurnStats.science.toInt()) if (cities.size > 0) tech.nextTurn(nextTurnStats.science.toInt())
for (city in cities) { for (city in cities) {
city.nextTurn() city.endTurn()
greatPeople.addGreatPersonPoints(city.getGreatPersonPoints()) greatPeople.addGreatPersonPoints(city.getGreatPersonPoints())
} }
@ -150,7 +150,17 @@ class CivilizationInfo {
addGreatPerson(greatPerson) 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) { fun addGreatPerson(greatPerson: String) {

View File

@ -22,7 +22,7 @@ class GoldenAgeManager {
civInfo.addNotification("You have entered a golden age!", null) civInfo.addNotification("You have entered a golden age!", null)
} }
fun nextTurn(happiness: Int) { fun endTurn(happiness: Int) {
if (happiness > 0 && !isGoldenAge()) storedHappiness += happiness if (happiness > 0 && !isGoldenAge()) storedHappiness += happiness
if (isGoldenAge()) if (isGoldenAge())

View File

@ -78,7 +78,7 @@ class PolicyManager {
cityInfo.cityStats.update() cityInfo.cityStats.update()
} }
fun nextTurn(culture: Int) { fun endTurn(culture: Int) {
val couldAdoptPolicyBefore = canAdoptPolicy() val couldAdoptPolicyBefore = canAdoptPolicy()
storedCulture += culture storedCulture += culture
if (!couldAdoptPolicyBefore && canAdoptPolicy()) if (!couldAdoptPolicyBefore && canAdoptPolicy())

View File

@ -90,11 +90,14 @@ class MapUnit {
otherTile.unit = this otherTile.unit = this
} }
fun nextTurn() { fun endTurn() {
doPostTurnAction() doPostTurnAction()
if(currentMovement==maxMovement.toFloat()){ // didn't move this turn if(currentMovement==maxMovement.toFloat()){ // didn't move this turn
heal() heal()
} }
}
fun startTurn(){
currentMovement = maxMovement.toFloat() currentMovement = maxMovement.toFloat()
doPreTurnAction() doPreTurnAction()
} }