Resolved #782 - Wonders are no longer built twice under "race conditions"

This commit is contained in:
Yair Morgenstern 2019-05-20 19:48:18 +03:00
parent 95a3a65c34
commit a54f68528f
2 changed files with 11 additions and 5 deletions

View File

@ -21,7 +21,7 @@ android {
applicationId "com.unciv.app" applicationId "com.unciv.app"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 28 targetSdkVersion 28
versionCode 243 versionCode 244
versionName "2.16.7" versionName "2.16.7"
} }

View File

@ -143,6 +143,8 @@ class CityConstructions {
} }
fun constructIfEnough(){ fun constructIfEnough(){
stopUnbuildableConstruction()
val construction = getConstruction(currentConstruction) val construction = getConstruction(currentConstruction)
if(construction is SpecialConstruction) return if(construction is SpecialConstruction) return
@ -154,10 +156,16 @@ class CityConstructions {
} }
fun endTurn(cityStats: Stats) { fun endTurn(cityStats: Stats) {
val construction = getConstruction(currentConstruction) stopUnbuildableConstruction()
if(construction is SpecialConstruction) return
if(getConstruction(currentConstruction) !is SpecialConstruction)
addProductionPoints(Math.round(cityStats.production))
}
private fun stopUnbuildableConstruction() {
// 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.) // 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.)
val construction = getConstruction(currentConstruction)
val saveCurrentConstruction = currentConstruction val saveCurrentConstruction = currentConstruction
currentConstruction = "" currentConstruction = ""
if (!construction.isBuildable(this)) { if (!construction.isBuildable(this)) {
@ -166,8 +174,6 @@ class CityConstructions {
chooseNextConstruction() chooseNextConstruction()
} else } else
currentConstruction = saveCurrentConstruction currentConstruction = saveCurrentConstruction
addProductionPoints(Math.round(cityStats.production))
} }
fun constructionComplete(construction: IConstruction) { fun constructionComplete(construction: IConstruction) {