From 2f482e284732c96c57c86abd733add9926891bd1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 21 Jan 2025 00:47:42 +0100 Subject: validate supply --- rules.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/rules.js b/rules.js index f2e48a3..58dad4c 100644 --- a/rules.js +++ b/rules.js @@ -2174,6 +2174,12 @@ function goto_supply_hussars() { game.supply.pool = [] game.supply.used = [] game.count = 0 + save_checkpoint() +} + +function end_supply_hussars() { + clear_checkpoint() + resume_supply() } function goto_supply_restore() { @@ -2274,7 +2280,7 @@ states.supply_hussars = { delete game.supply.used game.count = 0 - resume_supply() + goto_validate_supply() }, } @@ -6998,6 +7004,55 @@ states.validate_hussars_fail = { }, } +/* VALIDATE: SUPPLY */ + +function goto_validate_supply() { + game.proposal = 0 + for (let other of all_powers) + if (should_validate_promise(game.power, other, V_SUPPLY)) + game.proposal |= (1 << other) + resume_validate_supply() +} + +function resume_validate_supply() { + resume_validate_promise("validate_supply", end_supply_hussars) +} + +states.validate_supply = { + dont_snap: true, + inactive: "confirm that promises were kept", + prompt() { + let other = current_sequence_of_play().power + prompt("Did " + power_name[other] + " keep their supply promise?") + view.actions.keep = 1 + view.actions.break = 1 + view.actions.undo = 0 + }, + keep() { + resume_validate_supply() + }, + break() { + let other = game.power + restore_checkpoint() + game.proposal = other + game.state = "validate_supply_fail" + }, +} + +states.validate_supply_fail = { + dont_snap: true, + inactive: "supply", + prompt() { + prompt("Promise to " + power_name[game.proposal] + " was not kept.") + view.actions.resume = 1 + view.actions.undo = 0 + }, + resume() { + game.state = "supply_hussars" + delete game.proposal + }, +} + /* VALIDATE: MOVEMENT */ function should_validate_movement(power) { -- cgit v1.2.3