summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-06-22 00:27:58 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:31:29 +0100
commit57668a518552e0c09354f9ee21464737ee2b6aae (patch)
treeed5213d4aa442f823716df3dc5bb06f9e7b1b910
parent75f6b58dae1101606078bf18155bcc80dac0a688 (diff)
downloadpax-pamir-57668a518552e0c09354f9ee21464737ee2b6aae.tar.gz
Mark cards as used when paying for action costs too!
-rw-r--r--rules.js19
1 files 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()