From a8874fde796f8fa563a8a80aa429f3a7c40eec44 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Fri, 25 Oct 2024 13:14:16 +0100 Subject: Added power_card action --- play.js | 5 +++++ rules.js | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/play.js b/play.js index f0f4390..5ccf136 100644 --- a/play.js +++ b/play.js @@ -206,6 +206,11 @@ function on_click_card(evt) { evt.stopPropagation(); } } + if (is_action('power_card', card)) { + if (send_action('power_card', card)) { + evt.stopPropagation(); + } + } } } diff --git a/rules.js b/rules.js index 44bbef6..0d0dcc3 100644 --- a/rules.js +++ b/rules.js @@ -290,6 +290,10 @@ function gen_action_card(card){ gen_action("card", card) } +function gen_action_power_card(card){ + gen_action("power_card", card) +} + function gen_action_sc(space){ gen_action("sc", space) } @@ -1280,11 +1284,11 @@ states.raise_stakes_1 = { gen_action('pass') } for (let card of game.valid_cards) { - gen_action_card(card) + gen_action_power_card(card) } } }, - card(card) { + power_card(card) { push_undo() if (numberless_cards.includes(card)) { log(`Discarded: P${card}`) @@ -1343,11 +1347,11 @@ states.raise_stakes_2 = { gen_action('pass') } for (let card of game.valid_cards) { - gen_action_card(card) + gen_action_power_card(card) } } }, - card(card) { + power_card(card) { push_undo() if (numberless_cards.includes(card)) { log(`Discarded: P${card}`) @@ -1401,7 +1405,7 @@ states.power_struggle = { if (game.valid_cards.length > 0) { view.prompt = "Play a card." for (let card of game.valid_cards) { - gen_action_card(card) + gen_action_power_card(card) } } else if ( game.valid_cards.length === 0) { view.prompt = 'No valid cards. You must concede.' @@ -1413,7 +1417,7 @@ states.power_struggle = { view.prompt = `${power_cards[game.played_power_card].name} played. You must match or concede.` gen_action('concede') for (let card of game.valid_cards) { - gen_action_card(card) + gen_action_power_card(card) } } else if (game.valid_cards.length === 0) { view.prompt = `${power_cards[game.played_power_card].name} played. You must concede.` @@ -1432,7 +1436,7 @@ states.power_struggle = { if (game.tactics_fails !== "Petition") {gen_action('petition')} } }, - card(card) { + power_card(card) { push_undo() discard(card) game.valid_cards=[] -- cgit v1.2.3