diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-01-21 00:47:42 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-15 15:52:46 +0100 |
commit | 2f482e284732c96c57c86abd733add9926891bd1 (patch) | |
tree | 89b38c7e6f3160d0ad02468f1dab11ae042e3528 | |
parent | 7aee4d01ba6c2e932bd797c124145379da7f0a08 (diff) | |
download | maria-2f482e284732c96c57c86abd733add9926891bd1.tar.gz |
validate supply
-rw-r--r-- | rules.js | 57 |
1 files changed, 56 insertions, 1 deletions
@@ -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) { |