diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-12-03 12:56:59 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-12-03 13:29:16 +0100 |
commit | a70c6713d58552e6937604f053d59d04667be17c (patch) | |
tree | dd9a59b6cf3d78d303efe3a2c1179f4aa51c6358 /rules.js | |
parent | 33b88776cf150f196651c05334563c297a98e0f1 (diff) | |
download | maria-a70c6713d58552e6937604f053d59d04667be17c.tar.gz |
Notify all players of accepted subsidies.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 64 |
1 files changed, 46 insertions, 18 deletions
@@ -6241,7 +6241,7 @@ states.propose_subsidy_length = { let ctl_to = is_controlled_power(game.power, game.proposal.to) if (ctl_from && ctl_to) { create_subsidy() - end_propose_subsidy() + goto_notify_propose_subsidy() } else { set_active_to_power_keep_undo(game.proposal.from) game.state = "propose_subsidy_approve_from" @@ -6264,8 +6264,14 @@ states.propose_subsidy_approve_from = { view.actions.reject = 1 }, accept() { - set_active_to_power_keep_undo(game.proposal.to) - game.state = "propose_subsidy_approve_to" + // accept if 2nd party is same as 1st party or the initiator + if (is_controlled_power(game.proposal.save_power, game.proposal.to) || is_controlled_power(game.proposal.from, game.proposal.to)) { + create_subsidy() + goto_notify_propose_subsidy() + } else { + set_active_to_power_keep_undo(game.proposal.to) + game.state = "propose_subsidy_approve_to" + } }, reject() { goto_reject_propose_subsidy() @@ -6285,7 +6291,7 @@ states.propose_subsidy_approve_to = { }, accept() { create_subsidy() - end_propose_subsidy() + goto_notify_propose_subsidy() }, reject() { goto_reject_propose_subsidy() @@ -6293,33 +6299,41 @@ states.propose_subsidy_approve_to = { } function goto_reject_propose_subsidy() { + game.proposal.reject = 1 + goto_notify_propose_subsidy() +} + +function goto_notify_propose_subsidy() { if (game.power === game.proposal.to) set_active_to_power_keep_undo(game.proposal.from) else set_active_to_power_keep_undo(game.proposal.save_power) - game.state = "reject_propose_subsidy" + game.state = "notify_propose_subsidy" } -function next_reject_propose_subsidy() { +function next_notify_propose_subsidy() { if (game.power !== game.proposal.save_power) set_active_to_power_keep_undo(game.proposal.save_power) else end_propose_subsidy() } -states.reject_propose_subsidy = { +states.notify_propose_subsidy = { dont_snap: true, inactive: "resume play", prompt() { let from = game.proposal.from let to = game.proposal.to let n = game.proposal.n - prompt(`Subsidy contract from ${power_name[from]} to ${power_name[to]} for ${n} turns was NOT accepted.`) + if (game.proposal.reject) + prompt(`Subsidy contract from ${power_name[from]} to ${power_name[to]} for ${n} turns was NOT created.`) + else + prompt(`Subsidy contract from ${power_name[from]} to ${power_name[to]} for ${n} turns created.`) view.actions.resume = 1 view.actions.undo = 0 }, resume() { - next_reject_propose_subsidy() + next_notify_propose_subsidy() }, } @@ -6400,7 +6414,7 @@ states.cancel_subsidy_to = { let ctl_to = is_controlled_power(game.power, game.proposal.to) if (ctl_from && ctl_to) { cancel_subsidy() - end_cancel_subsidy() + goto_notify_cancel_subsidy() } else { set_active_to_power_keep_undo(game.proposal.from) game.state = "cancel_subsidy_approve_from" @@ -6423,8 +6437,14 @@ states.cancel_subsidy_approve_from = { view.actions.reject = 1 }, accept() { - set_active_to_power_keep_undo(game.proposal.to) - game.state = "cancel_subsidy_approve_to" + // accept immediately if 2nd party is same as 1st party or the initiator + if (is_controlled_power(game.proposal.save_power, game.proposal.to) || is_controlled_power(game.proposal.from, game.proposal.to)) { + cancel_subsidy() + goto_notify_cancel_subsidy() + } else { + set_active_to_power_keep_undo(game.proposal.to) + game.state = "cancel_subsidy_approve_to" + } }, reject() { goto_reject_cancel_subsidy() @@ -6444,7 +6464,7 @@ states.cancel_subsidy_approve_to = { }, accept() { cancel_subsidy() - end_cancel_subsidy() + goto_notify_cancel_subsidy() }, reject() { goto_reject_cancel_subsidy() @@ -6452,32 +6472,40 @@ states.cancel_subsidy_approve_to = { } function goto_reject_cancel_subsidy() { + game.proposal.reject = 1 + goto_notify_cancel_subsidy() +} + +function goto_notify_cancel_subsidy() { if (game.power === game.proposal.to) set_active_to_power_keep_undo(game.proposal.from) else set_active_to_power_keep_undo(game.proposal.save_power) - game.state = "reject_cancel_subsidy" + game.state = "notify_cancel_subsidy" } -function next_reject_cancel_subsidy() { +function next_notify_cancel_subsidy() { if (game.power !== game.proposal.save_power) set_active_to_power_keep_undo(game.proposal.save_power) else end_cancel_subsidy() } -states.reject_cancel_subsidy = { +states.notify_cancel_subsidy = { dont_snap: true, inactive: "resume play", prompt() { let from = game.proposal.from let to = game.proposal.to - prompt(`Subsidy from ${power_name[from]} to ${power_name[to]} was NOT canceled.`) + if (game.proposal.reject) + prompt(`Subsidy from ${power_name[from]} to ${power_name[to]} was NOT canceled.`) + else + prompt(`Subsidy from ${power_name[from]} to ${power_name[to]} canceled.`) view.actions.resume = 1 view.actions.undo = 0 }, resume() { - next_reject_cancel_subsidy() + next_notify_cancel_subsidy() }, } |