summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-30 22:00:50 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:26 +0100
commitd109a4fa1d646c7f1066d86e5f1ca01ce9bc00cc (patch)
tree0c916d10d6229e08f0cdce34a8b25e4ef16fbf2f
parente8ee549f0d30c5caa99b2d931734c5f18332d543 (diff)
downloadrommel-in-the-desert-d109a4fa1d646c7f1066d86e5f1ca01ce9bc00cc.tar.gz
Fix awkward selection/undo during buildup.
-rw-r--r--rules.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/rules.js b/rules.js
index 141d56b..d146a96 100644
--- a/rules.js
+++ b/rules.js
@@ -4677,9 +4677,16 @@ states.spending_bps = {
gen_action('end_buildup')
},
unit(who) {
- if (game.selected < 0)
+ if (game.selected < 0) {
push_undo()
- apply_select(who)
+ game.selected = who
+ game.changed = 0
+ } else {
+ if (!game.changed)
+ pop_undo()
+ else
+ game.selected = -1
+ }
},
extra_supply_card() {
push_undo()
@@ -4691,16 +4698,19 @@ states.spending_bps = {
game.state = 'minefield'
},
replacement() {
+ game.changed = 1
log(`Replaced unit.`)
replace_unit(game.selected)
pay_bps(replacement_cost(game.selected))
},
refit() {
+ game.changed = 1
log(`Returned for Refit.`)
hide_unit(game.selected)
set_unit_hex(pop_selected(), friendly_refit())
},
hex(to) {
+ game.changed = 1
let who = game.selected
let from = unit_hex(who)
if (to === from) {
@@ -4732,6 +4742,7 @@ states.spending_bps = {
}
},
end_buildup() {
+ delete game.changed
clear_undo()
let n = available_bps()