From 006c34ed997c8aeb9836ad6a41d5ab3fe4a44a33 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 26 May 2022 16:21:49 +0200 Subject: Manually discard events and instability dominance checks. --- rules.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/rules.js b/rules.js index 3804aa6..5862763 100644 --- a/rules.js +++ b/rules.js @@ -2357,6 +2357,14 @@ states.cleanup_hand = { } } +function goto_discard_events() { + if (is_event_card(game.market_cards[0][0]) || is_event_card(game.market_cards[1][0])) { + game.state = 'discard_events'; + } else { + goto_refill_market(); + } +} + function do_discard_event(row, c) { game.market_cards[row][0] = 0; logbr(); @@ -2368,14 +2376,22 @@ function do_discard_event(row, c) { } } -function goto_discard_events() { - if (is_event_card(game.market_cards[0][0])) { - do_discard_event(0, game.market_cards[0][0]); - } else if (is_event_card(game.market_cards[1][0])) { - do_discard_event(1, game.market_cards[1][0]); - } else { - goto_refill_market(); - } +states.discard_events = { + inactive: "discard event cards", + prompt() { + view.prompt = `Discard any event cards in the leftmost column of the market.`; + if (is_event_card(game.market_cards[0][0])) + gen_action('card', game.market_cards[0][0]); + else if (is_event_card(game.market_cards[1][0])) + gen_action('card', game.market_cards[1][0]); + }, + card(c) { + push_undo(); + if (c === game.market_cards[0][0]) + do_discard_event(0, c); + else + do_discard_event(1, c); + }, } function discard_instability_cards() { @@ -2418,6 +2434,8 @@ function goto_refill_market() { } } + clear_undo(); + // Fill with new cards from left (top row in each column first) for (let col = 0; col < 6; ++col) { for (let row = 0; row < 2; ++row) { @@ -2426,10 +2444,8 @@ function goto_refill_market() { let c = game.deck.pop(); game.market_cards[row][col] = c; if (instability > 0 && is_dominance_check(c)) { - logbr(); - log(`Instability!`); - discard_instability_cards(); - return do_dominance_check('instability'); + game.state = 'instability'; + return; } } } @@ -2439,6 +2455,25 @@ function goto_refill_market() { goto_next_player(); } +states.instability = { + prompt() { + view.prompt = "Instability \u2014 perform a Dominance Check immediately."; + for (let row = 0; row < 2; ++row) { + for (let col = 0; col < 6; ++col) { + let c = game.market_cards[row][col]; + if (is_dominance_check(c)) + gen_action('card', c); + } + } + }, + card(c) { + logbr(); + log(`Instability!`); + discard_instability_cards(); + do_dominance_check('instability'); + } +} + // EVENTS: IF DISCARDED const events_if_discarded = { -- cgit v1.2.3