diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 1bd698333c..c514d2db1d 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -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) { diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index c217057354..ba30af14d1 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -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-- diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 86985d4b7f..2465f82d0d 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -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()} diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 7e188c7eca..1d13231577 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -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") }