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
if (cityConstructions.currentConstruction == CityConstructions.Settler && stats.food > 0) {
stats.production += stats.food

View file

@ -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) {

View file

@ -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())

View file

@ -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())

View file

@ -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()
}