From 21c5f6f5012e7ef07c51ee5d03e4d3bf55f5f801 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 25 Jan 2025 17:34:00 +0100 Subject: validate imperial election --- rules.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index cb77a13..5c4018a 100644 --- a/rules.js +++ b/rules.js @@ -6187,9 +6187,12 @@ function goto_imperial_election() { game.stage = 0 set_active_to_power(P_AUSTRIA) log(power_name[game.power]) + + save_checkpoint() } function next_imperial_election() { + clear_checkpoint() if (game.power === P_FRANCE) { set_active_to_power(P_BAVARIA) } else if (coop_major_power(P_SAXONY) === game.power) { @@ -6202,6 +6205,7 @@ function next_imperial_election() { set_active_to_power(POWER_FROM_IMPERIAL_ELECTION_STAGE[game.stage]) } log(power_name[game.power]) + save_checkpoint() } states.imperial_election = { @@ -6242,7 +6246,7 @@ states.imperial_election = { } } - next_imperial_election() + goto_validate_election() }, pass() { log(">No votes") @@ -7278,6 +7282,55 @@ states.validate_winter_fail = { }, } +/* VALIDATE: IMPERIAL ELECTION */ + +function goto_validate_election() { + game.proposal = 0 + for (let other of all_powers) + if (should_validate_promise(game.power, other, V_ELECTION)) + game.proposal |= (1 << other) + resume_validate_election() +} + +function resume_validate_election() { + resume_validate_promise("validate_election", next_imperial_election) +} + +states.validate_election = { + dont_snap: true, + inactive: "confirm that promises were kept", + prompt() { + let other = current_sequence_of_play().power + prompt("Did " + power_name[other] + " keep their imperial election promise?") + view.actions.keep = 1 + view.actions.break = 1 + view.actions.undo = 0 + }, + keep() { + next_imperial_election() + }, + break() { + let other = game.power + restore_checkpoint() + game.proposal = other + game.state = "validate_election_fail" + }, +} + +states.validate_election_fail = { + dont_snap: true, + inactive: "vote in the imperial election", + prompt() { + prompt("Promise to " + power_name[game.proposal] + " was not kept.") + view.actions.resume = 1 + view.actions.undo = 0 + }, + resume() { + game.state = "imperial_election" + delete game.proposal + }, +} + /* SETUP */ const POWER_FROM_SETUP_STAGE = [ -- cgit v1.2.3