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
@ -34,14 +34,13 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
|
|
||||||
rightSideButton.setText("Pick promotion".tr())
|
rightSideButton.setText("Pick promotion".tr())
|
||||||
rightSideButton.onClick(UncivSound.Promote) {
|
rightSideButton.onClick(UncivSound.Promote) {
|
||||||
acceptPromotion(selectedPromotion)
|
acceptPromotion(selectedPromotion)
|
||||||
}
|
}
|
||||||
val canBePromoted = unit.promotions.canBePromoted()
|
val canBePromoted = unit.promotions.canBePromoted()
|
||||||
val canChangeState = game.worldScreen.canChangeState
|
val canChangeState = game.worldScreen.canChangeState
|
||||||
val canPromoteNow = canBePromoted && canChangeState
|
val canPromoteNow = canBePromoted && canChangeState
|
||||||
&& unit.currentMovement > 0 && unit.attacksThisTurn == 0
|
&& unit.currentMovement > 0 && unit.attacksThisTurn == 0
|
||||||
if (!canPromoteNow)
|
rightSideButton.isEnabled = canPromoteNow
|
||||||
rightSideButton.isEnabled = false
|
|
||||||
|
|
||||||
val availablePromotionsGroup = Table()
|
val availablePromotionsGroup = Table()
|
||||||
availablePromotionsGroup.defaults().pad(5f)
|
availablePromotionsGroup.defaults().pad(5f)
|
||||||
@ -89,7 +88,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
|
|
||||||
availablePromotionsGroup.add(selectPromotionButton)
|
availablePromotionsGroup.add(selectPromotionButton)
|
||||||
|
|
||||||
if (canBePromoted && isPromotionAvailable && canChangeState) {
|
if (canPromoteNow && isPromotionAvailable) {
|
||||||
val pickNow = "Pick now!".toLabel()
|
val pickNow = "Pick now!".toLabel()
|
||||||
pickNow.setAlignment(Align.center)
|
pickNow.setAlignment(Align.center)
|
||||||
pickNow.onClick {
|
pickNow.onClick {
|
||||||
@ -108,7 +107,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
displayTutorial(Tutorial.Experience)
|
displayTutorial(Tutorial.Experience)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setScrollY(scrollY: Float): PromotionPickerScreen {
|
private fun setScrollY(scrollY: Float): PromotionPickerScreen {
|
||||||
splitPane.pack() // otherwise scrollPane.maxY == 0
|
splitPane.pack() // otherwise scrollPane.maxY == 0
|
||||||
scrollPane.scrollY = scrollY
|
scrollPane.scrollY = scrollY
|
||||||
scrollPane.updateVisualScroll()
|
scrollPane.updateVisualScroll()
|
||||||
|
@ -226,7 +226,7 @@ object UnitActions {
|
|||||||
|
|
||||||
private fun addPromoteAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
private fun addPromoteAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
if (unit.isCivilian() || !unit.promotions.canBePromoted()) return
|
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,
|
actionList += UnitAction(UnitActionType.Promote,
|
||||||
action = {
|
action = {
|
||||||
UncivGame.Current.setScreen(PromotionPickerScreen(unit))
|
UncivGame.Current.setScreen(PromotionPickerScreen(unit))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user