diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-07-21 16:46:01 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-08-21 00:28:20 +0200 |
commit | ef6dc279b0aa0fc8a69d41458021e4fdbc6ec853 (patch) | |
tree | 7c251d18cd930f845f7e0ac83eaee2d36789c198 | |
parent | d52f685bdf30b6e67a0be0456363378e14a432bc (diff) | |
download | washingtons-war-ef6dc279b0aa0fc8a69d41458021e4fdbc6ec853.tar.gz |
exchange before playing cards
-rw-r--r-- | rules.js | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -306,9 +306,12 @@ function discard_card(c, reason) { function can_exchange_for_discard(c) { if (game.did_discard_event) { - if (game.active === P_BRITAIN) - return true - return CARDS[c].count > 1 + let card = CARDS[c] + if (card.type === "ops") { + if (game.active === P_BRITAIN) + return CARDS[c].count > 0 + return CARDS[c].count > 1 + } } return false } @@ -1268,8 +1271,11 @@ states.strategy_phase = { inactive: "to play a strategy card", prompt() { view.prompt = "Play a strategy card." - for (let c of active_hand()) + for (let c of active_hand()) { gen_action_card("card", c) + if (can_exchange_for_discard(c)) + view.actions.exchange = 1 + } }, card(c) { push_undo() @@ -1284,6 +1290,29 @@ states.strategy_phase = { break } }, + exchange() { + push_undo() + let d = game.did_discard_event + set_add(active_hand(), d) + logp("picked up up #" + d) + game.state = "exchange" + }, +} + +states.exchange = { + inactive: "to play a strategy card", + prompt() { + view.prompt = "Exchange an OPS card for the event card." + view.selected_card = game.did_discard_event + for (let c of active_hand()) + if (can_exchange_for_discard(c)) + gen_action_card("card", c) + }, + card(c) { + game.did_discard_event = 0 + discard_card(c, "exchange") + game.state = "strategy_phase" + }, } states.strategy_phase_ops = { |