summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-04-02 17:56:15 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit480babd1cec0c88c09c42d8faea15bd84efc054e (patch)
tree2e39e53041fe58bdcca27c464041c3a1be5fab19
parent41df62d795a5cb1ba91f74686729b6be1c8048e5 (diff)
downloadwilderness-war-480babd1cec0c88c09c42d8faea15bd84efc054e.tar.gz
Confirm ending force designation with no units picked up.
-rw-r--r--rules.js57
1 files changed, 39 insertions, 18 deletions
diff --git a/rules.js b/rules.js
index 26dd1e0..4a13e90 100644
--- a/rules.js
+++ b/rules.js
@@ -2591,24 +2591,10 @@ states.designate_force = {
next() {
push_undo();
- let commander = game.force.commander;
- let reason = game.force.reason;
- delete game.force;
- switch (reason) {
- case 'campaign_1':
- game.activation.push(commander);
- game.state = 'select_campaign_2';
- break;
- case 'campaign_2':
- game.activation.push(commander);
- goto_pick_first_move();
- break;
- case 'move':
- goto_move_piece(commander);
- break;
- default:
- throw Error("unknown reason state: " + game.reason);
- }
+ if (game.force.reason === 'move' && count_units_in_force(game.force.commander) === 0)
+ game.state = 'confirm_designate_force';
+ else
+ end_designate_force();
},
intercept() {
attempt_intercept();
@@ -2618,6 +2604,41 @@ 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;
+ gen_action('next');
+ },
+ next() {
+ end_designate_force();
+ }
+}
+
+function end_designate_force() {
+ let commander = game.force.commander;
+ let reason = game.force.reason;
+ delete game.force;
+ switch (reason) {
+ case 'campaign_1':
+ game.activation.push(commander);
+ game.state = 'select_campaign_2';
+ break;
+ case 'campaign_2':
+ game.activation.push(commander);
+ goto_pick_first_move();
+ break;
+ case 'move':
+ goto_move_piece(commander);
+ break;
+ default:
+ throw Error("unknown reason state: " + game.reason);
+ }
+}
+
// TODO: merge with designate_force using reason=intercept_lone_ax
states.designate_force_lone_ax = {
inactive() {