diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-12-17 19:56:17 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-12-17 19:56:17 +0100 |
commit | 64680dffca07b65cfade66a28578ddcb4269489e (patch) | |
tree | ee6eeffd65113c066a919c71d16f6a74b46a8aee /rules.js | |
parent | 29e0524e7122ec48a7250bd1d7ff58c5c149191b (diff) | |
download | pax-pamir-64680dffca07b65cfade66a28578ddcb4269489e.tar.gz |
Add "ping" action.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 58 |
1 files changed, 54 insertions, 4 deletions
@@ -903,6 +903,46 @@ function end_bribe() { do_play_2() } +// PING + +states.ping = { + inactive: "ping", + prompt() { + view.prompt = "Choose which player to respond to chat?" + for (let p = 0; p < game.players.length; ++p) + if (p !== game.active) + gen_action('player_' + p) + view.actions.undo = 1 + }, + player_0() { do_ping_player(0) }, + player_1() { do_ping_player(1) }, + player_2() { do_ping_player(2) }, + player_3() { do_ping_player(3) }, + player_4() { do_ping_player(4) }, + undo() { + states.pong.resume() + }, +} + +function do_ping_player(p) { + game.active = p + game.state = "pong" +} + +states.pong = { + inactive: "ping", + prompt() { + view.prompt = player_names[game.ping.active] + " has requested your response in chat." + view.actions.resume = 1 + view.actions.undo = 0 + }, + resume() { + game.active = game.ping.active + game.state = game.ping.state + delete game.ping + }, +} + // STARTING LOYALTY states.loyalty = { @@ -1060,6 +1100,14 @@ states.actions = { if (bonus) view.prompt += ` You may take bonus actions.` + // Ping another player + if (game.players.length > 2) + gen_action('ping') + }, + + ping() { + game.ping = { active: game.active, state: game.state } + game.state = "ping" }, // Purchase card from market @@ -3252,10 +3300,12 @@ exports.view = function (state, current) { view.actions = {} states[game.state].prompt() view.prompt = player_names[game.active] + ": " + view.prompt - if (game.undo && game.undo.length > 0) - view.actions.undo = 1 - else - view.actions.undo = 0 + if (view.actions.undo === undefined) { + if (game.undo && game.undo.length > 0) + view.actions.undo = 1 + else + view.actions.undo = 0 + } } save_game() |