From 2a320ebe8ba6148979fb2c501a197b972aa1facf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 15 Sep 2024 11:09:39 +0200 Subject: Confirm dummy actions with alert prompts in client. - Designate force without units. - End individual activation with points left. - End movement without moving. --- play.js | 14 ++++++++++++++ rules.js | 67 ++++++++++++++++++++++++---------------------------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/play.js b/play.js index 6fc6fd7..db0d5ce 100644 --- a/play.js +++ b/play.js @@ -1548,6 +1548,17 @@ function update_map() { action_button("exchange", "Exchange") action_button("stop", "Stop") + // confirm "dummy" actions + confirm_action_button("confirm_end_activations", "End activations", + "SKIP the remaining individual ACTIVATIONS?" + ) + confirm_action_button("confirm_activate", "Activate", + "ACTIVATE leader to MOVE ALONE?" + ) + confirm_action_button("confirm_end_move", "End move", + "END MOVE without MOVING?" + ) + confirm_action_button("pass_bh_season", "Pass season", "PASS on playing \"Blockhouses\" for the rest of this SEASON?" ) @@ -1563,8 +1574,11 @@ function update_map() { action_button("pass", "Pass") action_button("next", "Next") + + action_button("end_activations", "End activations") action_button("end_construction", "End construction") action_button("end_move", "End move") + action_button("undo", "Undo") } diff --git a/rules.js b/rules.js index 8ed37cb..515aafc 100644 --- a/rules.js +++ b/rules.js @@ -2381,7 +2381,10 @@ events.campaign = { states.activate_individually = { prompt() { view.prompt = `Activate units and/or leaders individually${format_remain(game.count)}.` - view.actions.next = 1 + if (game.count > 0) + view.actions.confirm_end_activations = 1 + else + view.actions.end_activations = 1 if (game.count >= 1) { for (let p = first_friendly_leader; p <= last_friendly_leader; ++p) { if (is_piece_on_map(p) && !game.activation.includes(p)) { @@ -2419,7 +2422,10 @@ states.activate_individually = { else game.count -= 1.0 }, - next() { + confirm_end_activations() { + this.end_activations() + }, + end_activations() { push_undo() goto_pick_first_move() }, @@ -2640,7 +2646,10 @@ states.designate_force = { case 'campaign_2': case 'move': // Campaign and normal activations can activate leaders without forces. - view.actions.activate = 1 + if (count_units_in_force(game.force.commander) > 0) + view.actions.activate = 1 + else + view.actions.confirm_activate = 1 break case 'intercept': // Must be a force to proceed (leader + at least one unit) @@ -2700,10 +2709,10 @@ states.designate_force = { activate() { push_undo() - if (game.force.reason === 'move' && count_units_in_force(game.force.commander) === 0) - game.state = 'confirm_designate_force' - else - end_designate_force() + end_designate_force() + }, + confirm_activate() { + this.activate() }, intercept() { attempt_intercept() @@ -2713,20 +2722,6 @@ states.designate_force = { }, } -states.confirm_designate_force = { - inactive() { - inactive_prompt("designate force " + designate_force_reason_prompt[game.force.reason], game.force.commander, 0) - }, - prompt() { - view.prompt = `You have not picked up any units \u2014 are you sure you want to continue?` - view.who = game.force.commander - view.actions.next = 1 - }, - next() { - end_designate_force() - } -} - function end_designate_force() { let commander = game.force.commander let reason = game.force.reason @@ -3403,7 +3398,10 @@ states.move = { else if (game.move.used === 9) view.actions.end_move = 1 } else { - view.actions.end_move = 1 + if (game.move.used > 0) + view.actions.end_move = 1 + else + view.actions.confirm_end_move = 1 } if (game.move.used < max_movement_cost(game.move.type)) { @@ -3469,12 +3467,11 @@ states.move = { goto_designate_inside() }, end_move() { - if (game.move.used > 0) { - end_move() - } else { - push_undo() - game.state = 'confirm_end_move' - } + clear_undo() + end_move() + }, + confirm_end_move() { + this.end_move() }, } @@ -3530,20 +3527,6 @@ states.drop_off = { }, } -states.confirm_end_move = { - inactive() { - inactive_prompt("move", moving_piece(), 0) - }, - prompt() { - view.prompt = `You have not moved yet \u2014 are you sure you want to pass?` - view.who = moving_piece() - view.actions.end_move = 1 - }, - end_move() { - end_move() - } -} - function goto_retroactive_foul_weather() { if (game.options.retroactive && game.retro_foul_weather) { // console.log("RETRO REWIND") -- cgit v1.2.3