From d109a4fa1d646c7f1066d86e5f1ca01ce9bc00cc Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 30 Jul 2022 22:00:50 +0200 Subject: Fix awkward selection/undo during buildup. --- rules.js | 15 +++++++++++++-- 1 file 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() -- cgit v1.2.3