diff options
-rw-r--r-- | rules.js | 144 |
1 files changed, 135 insertions, 9 deletions
@@ -5862,10 +5862,12 @@ function goto_prussia_ends_neutrality() { } function goto_prussia_annexes_silesia() { - if (has_prussia_conquered_silesia()) + if (has_prussia_conquered_silesia()) { game.state = "offer_peace" - else + save_checkpoint() + } else { next_sequence_of_play() + } } function is_prussia_neutral() { @@ -5896,15 +5898,29 @@ states.offer_peace = { }, peace() { log("Annexion of Silesia proposed.") - set_active_to_power(P_AUSTRIA) - game.state = "accept_peace" + game.silesia = 1 + goto_validate_offer_peace() }, pass() { - log("Annexion of Silesia passed.") - next_sequence_of_play() + log("Annexion of Silesia skipped.") + game.silesia = 0 + goto_validate_offer_peace() }, } +function end_offer_peace() { + clear_checkpoint() + if (game.silesia) { + delete game.silesia + set_active_to_power(P_AUSTRIA) + game.state = "accept_peace" + save_checkpoint() + } else { + delete game.silesia + next_sequence_of_play() + } +} + states.accept_peace = { inactive: "accept peace", prompt() { @@ -5914,14 +5930,27 @@ states.accept_peace = { }, accept() { log("Austria accepts peace.") - goto_annex_silesia() + game.silesia = 1 + goto_validate_accept_peace() }, reject() { log("Austria refuses peace.") - next_sequence_of_play() + game.silesia = 0 + goto_validate_accept_peace() }, } +function end_accept_peace() { + clear_checkpoint() + if (game.silesia) { + delete game.silesia + goto_annex_silesia() + } else { + delete game.silesia + next_sequence_of_play() + } +} + function goto_annex_silesia() { log_br() log("=1 Annexion of Silesia") @@ -6092,7 +6121,7 @@ states.silesia_done = { view.actions.next = 1 }, next() { - next_sequence_of_play() + goto_validate_accept_peace() } } @@ -7284,6 +7313,103 @@ states.validate_winter_fail = { }, } +/* VALIDATE: SILESIA ANNEXION (OFFER PEACE) */ + +function goto_validate_offer_peace() { + game.proposal = 0 + for (let other of all_powers) + if (should_validate_promise(P_PRUSSIA, other, V_SILESIA)) + game.proposal |= (1 << other) + resume_validate_offer_peace() +} + +function resume_validate_offer_peace() { + resume_validate_promise("validate_offer_peace", end_offer_peace) +} + +states.validate_offer_peace = { + dont_snap: true, + inactive: "confirm that promises were kept", + prompt() { + prompt("Did Prussia keep their Silesia annexion promise?") + view.actions.keep = 1 + view.actions.break = 1 + view.actions.undo = 0 + }, + keep() { + end_offer_peace() + }, + break() { + let other = game.power + restore_checkpoint() + game.proposal = other + game.state = "validate_offer_peace_fail" + }, +} + +states.validate_offer_peace_fail = { + dont_snap: true, + inactive: "offer peace", + prompt() { + prompt("Promise to " + power_name[game.proposal] + " was not kept.") + view.actions.resume = 1 + view.actions.undo = 0 + }, + resume() { + game.state = "offer_peace" + delete game.proposal + }, +} + +/* VALIDATE: SILESIA ANNEXION (ACCEPT PEACE) */ + +function goto_validate_accept_peace() { + game.proposal = 0 + for (let other of all_powers) { + if (should_validate_promise(P_AUSTRIA, other, V_SILESIA)) + game.proposal |= (1 << other) + } + resume_validate_accept_peace() +} + +function resume_validate_accept_peace() { + resume_validate_promise("validate_accept_peace", end_accept_peace) +} + +states.validate_accept_peace = { + dont_snap: true, + inactive: "confirm that promises were kept", + prompt() { + prompt("Did Austria keep their Silesia annexion promise?") + view.actions.keep = 1 + view.actions.break = 1 + view.actions.undo = 0 + }, + keep() { + end_accept_peace() + }, + break() { + let other = game.power + restore_checkpoint() + game.proposal = other + game.state = "validate_accept_peace_fail" + }, +} + +states.validate_accept_peace_fail = { + dont_snap: true, + inactive: "accept peace", + prompt() { + prompt("Promise to " + power_name[game.proposal] + " was not kept.") + view.actions.resume = 1 + view.actions.undo = 0 + }, + resume() { + game.state = "accept_peace" + delete game.proposal + }, +} + /* VALIDATE: REDUCE MILITARY OBJECTIVES */ function goto_validate_military() { |