mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
Fixed bug where injured units would try to heal by pillaging barbarian encampments
This commit is contained in:
@ -14,25 +14,26 @@ import com.unciv.models.gamebasics.tr
|
|||||||
import com.unciv.models.gamebasics.unit.Promotion
|
import com.unciv.models.gamebasics.unit.Promotion
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
|
class PromotionPickerScreen(val mapUnit: MapUnit) : PickerScreen() {
|
||||||
private var selectedPromotion: Promotion? = null
|
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 {
|
init {
|
||||||
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
|
onBackButtonClicked { UnCivGame.Current.setWorldScreen() }
|
||||||
setDefaultCloseAction()
|
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.setText("Pick promotion".tr())
|
||||||
rightSideButton.onClick("promote") {
|
rightSideButton.onClick("promote") {
|
||||||
accept(selectedPromotion)
|
acceptPromotion(selectedPromotion)
|
||||||
}
|
}
|
||||||
|
|
||||||
val availablePromotionsGroup = VerticalGroup()
|
val availablePromotionsGroup = VerticalGroup()
|
||||||
@ -76,7 +77,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
|
|||||||
val pickNow = "Pick now!".toLabel()
|
val pickNow = "Pick now!".toLabel()
|
||||||
pickNow.setAlignment(Align.center)
|
pickNow.setAlignment(Align.center)
|
||||||
pickNow.onClick {
|
pickNow.onClick {
|
||||||
accept(promotion)
|
acceptPromotion(promotion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
add("Version".toLabel())
|
add("Version".toLabel())
|
||||||
add(UnCivGame.Current.version.toLabel()).row()
|
add(UnCivGame.Current.version.toLabel()).row()
|
||||||
|
|
||||||
addButton("Close"){ remove() }
|
addButton("Close"){ remove() }.colspan(2)
|
||||||
|
|
||||||
pack() // Needed to show the background.
|
pack() // Needed to show the background.
|
||||||
center(UnCivGame.Current.worldScreen.stage)
|
center(UnCivGame.Current.worldScreen.stage)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen.unit
|
package com.unciv.ui.worldscreen.unit
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.automation.UnitAutomation
|
import com.unciv.logic.automation.UnitAutomation
|
||||||
import com.unciv.logic.automation.WorkerAutomation
|
import com.unciv.logic.automation.WorkerAutomation
|
||||||
@ -257,6 +258,7 @@ class UnitActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun canPillage(unit: MapUnit, tile: TileInfo): Boolean {
|
fun canPillage(unit: MapUnit, tile: TileInfo): Boolean {
|
||||||
|
if(tile.improvement==null || tile.improvement==Constants.barbarianEncampment) return false
|
||||||
val tileOwner = tile.getOwner()
|
val tileOwner = tile.getOwner()
|
||||||
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
|
// 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)
|
return tileOwner==null || tileOwner==unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)
|
||||||
|
Reference in New Issue
Block a user