From 6856301504d8c55667aab21378e7ee602b456f42 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 5 Feb 2019 20:04:07 +0200 Subject: [PATCH] Resolved #446 - Buildings are now created when production is completed by Great Engineers, so production of the current turn can be added to the next construction --- android/build.gradle | 4 ++-- core/src/com/unciv/logic/city/CityConstructions.kt | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 37cf80d0..a8b5f661 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 199 - versionName "2.13.0" + versionCode 200 + versionName "2.13.1" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 310b95f4..1bd69833 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -2,7 +2,6 @@ package com.unciv.logic.city import com.badlogic.gdx.graphics.Color import com.unciv.logic.automation.Automation -import com.unciv.logic.civilization.PlayerType import com.unciv.models.gamebasics.Building import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tr @@ -124,10 +123,16 @@ class CityConstructions { fun addProduction(productionToAdd: Int) { if (!inProgressConstructions.containsKey(currentConstruction)) inProgressConstructions[currentConstruction] = 0 inProgressConstructions[currentConstruction] = inProgressConstructions[currentConstruction]!! + productionToAdd + + val construction = getConstruction(currentConstruction) + val productionCost = construction.getProductionCost(cityInfo.civInfo.policies.adoptedPolicies) + if (inProgressConstructions[currentConstruction]!! >= productionCost) { + constructionComplete(construction) + } } fun nextTurn(cityStats: Stats) { - var construction = getConstruction(currentConstruction) + val construction = getConstruction(currentConstruction) if(construction is SpecialConstruction) return // Let's try to remove the building from the city, and see if we can still build it (we need to remove because of wonders etc.) @@ -137,15 +142,10 @@ class CityConstructions { // We can't build this building anymore! (Wonder has been built / resource is gone / etc.) cityInfo.civInfo.addNotification("[${cityInfo.name}] Cannot continue work on [$saveCurrentConstruction]", cityInfo.location, Color.BROWN) Automation().chooseNextConstruction(this) - construction = getConstruction(currentConstruction) } else currentConstruction = saveCurrentConstruction addProduction(Math.round(cityStats.production)) - val productionCost = construction.getProductionCost(cityInfo.civInfo.policies.adoptedPolicies) - if (inProgressConstructions[currentConstruction]!! >= productionCost) { - constructionComplete(construction) - } } fun constructionComplete(construction: IConstruction) {