Fixed bug where injured units would try to heal by pillaging barbarian encampments

This commit is contained in:
Yair Morgenstern 2019-06-05 23:14:52 +03:00
parent 5b884c0ecf
commit 827a6f7871
3 changed files with 14 additions and 11 deletions

View File

@ -14,25 +14,26 @@ import com.unciv.models.gamebasics.tr
import com.unciv.models.gamebasics.unit.Promotion
import com.unciv.ui.utils.*
class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
class PromotionPickerScreen(val mapUnit: MapUnit) : PickerScreen() {
private var selectedPromotion: Promotion? = null
fun acceptPromotion(promotion: Promotion?) {
mapUnit.promotions.addPromotion(promotion!!.name)
if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit)
else game.setWorldScreen()
dispose()
game.worldScreen.shouldUpdate=true
}
init {
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
setDefaultCloseAction()
fun accept(promotion: Promotion?) {
mapUnit.promotions.addPromotion(promotion!!.name)
if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit)
else game.setWorldScreen()
dispose()
game.worldScreen.shouldUpdate=true
}
rightSideButton.setText("Pick promotion".tr())
rightSideButton.onClick("promote") {
accept(selectedPromotion)
acceptPromotion(selectedPromotion)
}
val availablePromotionsGroup = VerticalGroup()
@ -76,7 +77,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
val pickNow = "Pick now!".toLabel()
pickNow.setAlignment(Align.center)
pickNow.onClick {
accept(promotion)
acceptPromotion(promotion)
}

View File

@ -75,7 +75,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
add("Version".toLabel())
add(UnCivGame.Current.version.toLabel()).row()
addButton("Close"){ remove() }
addButton("Close"){ remove() }.colspan(2)
pack() // Needed to show the background.
center(UnCivGame.Current.worldScreen.stage)

View File

@ -1,6 +1,7 @@
package com.unciv.ui.worldscreen.unit
import com.badlogic.gdx.graphics.Color
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.automation.UnitAutomation
import com.unciv.logic.automation.WorkerAutomation
@ -257,6 +258,7 @@ class UnitActions {
}
fun canPillage(unit: MapUnit, tile: TileInfo): Boolean {
if(tile.improvement==null || tile.improvement==Constants.barbarianEncampment) return false
val tileOwner = tile.getOwner()
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
return tileOwner==null || tileOwner==unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)