From 57668a518552e0c09354f9ee21464737ee2b6aae Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 Jun 2022 00:27:58 +0200 Subject: Mark cards as used when paying for action costs too! --- rules.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rules.js b/rules.js index 44ad947..d4cb017 100644 --- a/rules.js +++ b/rules.js @@ -511,8 +511,14 @@ function pay_action_cost(cost, offset) { } for (let i = 0; i < cost; i += 2) { - if (ra >= 0) game.market_coins[0][ra] ++ - if (rb >= 0) game.market_coins[1][rb] ++ + if (ra >= 0) { + mark_card_used(game.market_cards[0][ra]) + game.market_coins[0][ra] ++ + } + if (rb >= 0) { + mark_card_used(game.market_cards[1][rb]) + game.market_coins[1][rb] ++ + } ra = rightmost_card(0, ra-1) rb = rightmost_card(1, rb-1) } @@ -959,6 +965,11 @@ function goto_next_player() { goto_actions() } +function mark_card_used(c) { + if (!game.used_cards.includes(c)) + game.used_cards.push(c) +} + states.actions = { prompt() { // Pass / End turn @@ -1055,10 +1066,10 @@ states.actions = { for (let i = 0; i < col; ++i) { if (game.market_cards[row][i] > 0) { game.market_coins[row][i] += cost_per_card - game.used_cards.push(game.market_cards[row][i]) + mark_card_used(game.market_cards[row][i]) } else { game.market_coins[1-row][i] += cost_per_card - game.used_cards.push(game.market_cards[1-row][i]) + mark_card_used(game.market_cards[1-row][i]) } } check_public_withdrawal() -- cgit v1.2.3