Unit construction moved to the beginning of the turn, so they won't be generated out in the open and vulnerable to enemy attacks before you can control them - Kudos am-per-sand!

This commit is contained in:
Yair Morgenstern 2019-02-21 20:12:17 +02:00
parent 325ac06e97
commit 563bbaf021
4 changed files with 22 additions and 22 deletions

View file

@ -66,11 +66,6 @@ class CityConstructions {
return result
}
fun getAmountConstructedText(): String =
if (SpecialConstruction.getSpecialConstructions().any { it.name== currentConstruction}) ""
else " (" + getWorkDone(currentConstruction) + "/" +
getCurrentConstruction().getProductionCost(cityInfo.civInfo.policies.adoptedPolicies) + ")"
fun getCurrentConstruction(): IConstruction = getConstruction(currentConstruction)
fun isBuilt(buildingName: String): Boolean = builtBuildings.contains(buildingName)
@ -120,10 +115,12 @@ class CityConstructions {
builtBuildingObjects = ArrayList(builtBuildings.map { GameBasics.Buildings[it]!! })
}
fun addProduction(productionToAdd: Int) {
fun addProductionPoints(productionToAdd: Int) {
if (!inProgressConstructions.containsKey(currentConstruction)) inProgressConstructions[currentConstruction] = 0
inProgressConstructions[currentConstruction] = inProgressConstructions[currentConstruction]!! + productionToAdd
}
fun constructIfEnough(){
val construction = getConstruction(currentConstruction)
val productionCost = construction.getProductionCost(cityInfo.civInfo.policies.adoptedPolicies)
if (inProgressConstructions[currentConstruction]!! >= productionCost) {
@ -131,7 +128,7 @@ class CityConstructions {
}
}
fun nextTurn(cityStats: Stats) {
fun endTurn(cityStats: Stats) {
val construction = getConstruction(currentConstruction)
if(construction is SpecialConstruction) return
@ -145,7 +142,7 @@ class CityConstructions {
} else
currentConstruction = saveCurrentConstruction
addProduction(Math.round(cityStats.production))
addProductionPoints(Math.round(cityStats.production))
}
fun constructionComplete(construction: IConstruction) {

View file

@ -189,6 +189,9 @@ class CityInfo {
}
fun startTurn(){
// Construct units at the beginning of the turn,
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
cityConstructions.constructIfEnough()
cityStats.update()
tryUpdateRoadStatus()
attackedThisTurn = false
@ -202,7 +205,7 @@ class CityInfo {
stats.food = 0f
}
cityConstructions.nextTurn(stats)
cityConstructions.endTurn(stats)
expansion.nextTurn(stats.culture)
if(isBeingRazed){
population.population--

View file

@ -336,11 +336,17 @@ class CivilizationInfo {
}
fun startTurn(){
// Generate great people at the start of the turn,
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
val greatPerson = greatPeople.getNewGreatPerson()
if (greatPerson != null) addGreatPerson(greatPerson)
}
updateViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
setCitiesConnectedToCapitalTransients()
for (city in cities){
city.startTurn()
}
for (city in cities) city.startTurn()
happiness = getHappinessForNextTurn().values.sum().roundToInt()
getCivUnits().toList().forEach { it.startTurn() }
}
@ -375,15 +381,6 @@ class CivilizationInfo {
city.endTurn()
}
//if no city available, addGreatPerson will throw exception
if (cities.isNotEmpty()) {
val greatPerson = greatPeople.getNewGreatPerson()
if (greatPerson != null) {
addGreatPerson(greatPerson)
}
}
goldenAges.endTurn(happiness)
getCivUnits().forEach { it.endTurn() }
diplomacy.values.forEach{it.nextTurn()}

View file

@ -181,7 +181,10 @@ class UnitActions {
tile.getCity()!!.cityConstructions.getCurrentConstruction() is Building &&
(tile.getCity()!!.cityConstructions.getCurrentConstruction() as Building).isWonder
) {
tile.getCity()!!.cityConstructions.addProduction(300 + 30 * tile.getCity()!!.population.population) //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
tile.getCity()!!.cityConstructions.apply {
addProductionPoints(300 + 30 * tile.getCity()!!.population.population) //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
constructIfEnough()
}
unit.destroy()
}.sound("chimes")
}