mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 21:03:15 -04:00
Close little loophole allowing promoting a unit after moving or attacking (#6361)
This commit is contained in:
parent
abfbfd5429
commit
365cf0dc19
@ -40,8 +40,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
val canChangeState = game.worldScreen.canChangeState
|
||||
val canPromoteNow = canBePromoted && canChangeState
|
||||
&& unit.currentMovement > 0 && unit.attacksThisTurn == 0
|
||||
if (!canPromoteNow)
|
||||
rightSideButton.isEnabled = false
|
||||
rightSideButton.isEnabled = canPromoteNow
|
||||
|
||||
val availablePromotionsGroup = Table()
|
||||
availablePromotionsGroup.defaults().pad(5f)
|
||||
@ -89,7 +88,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
|
||||
availablePromotionsGroup.add(selectPromotionButton)
|
||||
|
||||
if (canBePromoted && isPromotionAvailable && canChangeState) {
|
||||
if (canPromoteNow && isPromotionAvailable) {
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
pickNow.setAlignment(Align.center)
|
||||
pickNow.onClick {
|
||||
@ -108,7 +107,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
displayTutorial(Tutorial.Experience)
|
||||
}
|
||||
|
||||
fun setScrollY(scrollY: Float): PromotionPickerScreen {
|
||||
private fun setScrollY(scrollY: Float): PromotionPickerScreen {
|
||||
splitPane.pack() // otherwise scrollPane.maxY == 0
|
||||
scrollPane.scrollY = scrollY
|
||||
scrollPane.updateVisualScroll()
|
||||
|
@ -226,7 +226,7 @@ object UnitActions {
|
||||
|
||||
private fun addPromoteAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
if (unit.isCivilian() || !unit.promotions.canBePromoted()) return
|
||||
// promotion does not consume movement points, so we can do it always
|
||||
// promotion does not consume movement points, but is not allowed if a unit has exhausted its movement or has attacked
|
||||
actionList += UnitAction(UnitActionType.Promote,
|
||||
action = {
|
||||
UncivGame.Current.setScreen(PromotionPickerScreen(unit))
|
||||
|
Loading…
x
Reference in New Issue
Block a user