Merge branch '3.6.7-patch2'

This commit is contained in:
Yair Morgenstern 2020-03-14 21:50:09 +02:00
commit feb786c9ee
2 changed files with 31 additions and 26 deletions

View File

@ -33,8 +33,8 @@ allprojects {
version = '1.0.1'
ext {
appName = "Unciv"
appCodeNumber = 394
appVersion = "3.6.7-patch1"
appCodeNumber = 395
appVersion = "3.6.7-patch2"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.1'

View File

@ -269,6 +269,34 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
return button
}
fun purchaseConstruction(construction: IConstruction) {
val city = cityScreen.city
val cityConstructions = city.cityConstructions
// We can't trust the isSelectedQueueEntry because that fails when we have the same unit as both the current construction and in the queue,
// and then we purchase the unit from the queue - see #2157
val constructionIsCurrentConstruction = construction.name==cityConstructions.currentConstruction
if (!cityConstructions.purchaseConstruction(construction.name)) {
Popup(cityScreen).apply {
add("No space available to place [${construction.name}] near [${city.name}]".tr()).row()
addCloseButton()
open()
}
return
}
if (isSelectedQueueEntry()) {
// currentConstruction is removed from the queue by purchaseConstruction
// to avoid conflicts with NextTurnAutomation
if (!constructionIsCurrentConstruction && cityConstructions.constructionQueue[selectedQueueEntry] == construction.name)
cityConstructions.removeFromQueue(selectedQueueEntry)
selectedQueueEntry = -2
cityScreen.selectedConstruction = null
}
if (!construction.shouldBeDisplayed(cityConstructions)) cityScreen.selectedConstruction = null
cityScreen.update()
}
private fun getBuyButton(construction: IConstruction?): TextButton {
val city = cityScreen.city
val cityConstructions = city.cityConstructions
@ -282,28 +310,6 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
button.setText("Buy".tr())
button.disable()
} else {
fun purchaseConstruction() {
if (!cityConstructions.purchaseConstruction(construction.name)) {
Popup(cityScreen).apply {
add("No space available to place [${construction.name}] near [${city.name}]".tr()).row()
addCloseButton()
open()
}
} else {
if (isSelectedQueueEntry()) {
// currentConstruction is removed from the queue by purchaseConstruction
// to avoid conflicts with NextTurnAutomation
if (!isSelectedCurrentConstruction() && cityConstructions.constructionQueue[selectedQueueEntry] == construction.name)
cityConstructions.removeFromQueue(selectedQueueEntry)
selectedQueueEntry = -2
cityScreen.selectedConstruction = null
}
if (!construction.shouldBeDisplayed(cityConstructions)) cityScreen.selectedConstruction = null
cityScreen.update()
}
}
val constructionGoldCost = construction.getGoldCost(city.civInfo)
button.setText("Buy".tr() + " " + constructionGoldCost)
button.add(ImageGetter.getStatIcon(Stat.Gold.name)).size(20f).padBottom(2f)
@ -314,12 +320,11 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
val purchasePrompt = "Currently you have [${city.civInfo.gold}] gold.".tr() + "\n\n" +
"Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr()
YesNoPopup(purchasePrompt, { purchaseConstruction() }, cityScreen, { cityScreen.update() }).open()
YesNoPopup(purchasePrompt, { purchaseConstruction(construction) }, cityScreen, { cityScreen.update() }).open()
}
if (constructionGoldCost > city.civInfo.gold)
button.disable()
}
button.labelCell.pad(5f)