diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-12-20 08:11:00 +0000 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-12-20 08:11:00 +0000 |
commit | 569fa9e276b0941e586494fc8bc83487af5e6a81 (patch) | |
tree | a6b7db46064b9cb48b74d2176488a00e6ccfdd45 | |
parent | c1353e54023269d58debec272514fc45dc0c7577 (diff) | |
download | 1989-dawn-of-freedom-569fa9e276b0941e586494fc8bc83487af5e6a81.tar.gz |
Fix General Strike and scoring cards
-rw-r--r-- | play.js | 1 | ||||
-rw-r--r-- | rules.js | 44 |
2 files changed, 21 insertions, 24 deletions
@@ -881,6 +881,7 @@ function on_update() { document.getElementById("discard_panel").classList.add("hide") ui.removed.replaceChildren() + console.log('view.strategy_removed', view.strategy_removed) for (let c of view.strategy_removed) ui.removed.appendChild(ui.cards[c]) @@ -280,7 +280,7 @@ exports.setup = function (seed, scenario, _options) { vm: null, vm_event: 0, - played_card: 0, + //played_card: 0, available_ops: 0, vm_available_ops: 0, valid_spaces: [], @@ -1944,7 +1944,6 @@ states.general_strike = { silent_discard(card) game.available_ops = get_card_ops(card) if (scoring_cards.includes(card)) { - game.played_card = card game.vm_event = card log(`Played C${card} for the event.`) game.return_state = 'end_round' @@ -2169,9 +2168,7 @@ states.stasi_play_card = { card(card) { push_undo() game.played_card = card - let find_card - find_card = game.democrat_hand.indexOf(card) - game.democrat_hand.splice(find_card, 1) + remove_from_hand(card) game.available_ops = get_card_ops(card) if (game.democrat_hand.includes(C_COMMON_EUROPEAN_HOME) && cards[card].side === "C") { @@ -3362,6 +3359,18 @@ function count_scoring_cards() { function select_card(card) { game.played_card = card game.temp = 0 + remove_from_hand(card) + game.state = 'play_card' +} +function finish_select_card() { + if (!scoring_cards.includes(game.played_card)) { + game.available_ops = get_card_ops(game.played_card) + if (game.state !== 'stasi_play_ceh') + log(`Played C${game.played_card}.`) + } +} + +function remove_from_hand(card) { let find_card if (game.active === COM) { find_card = game.communist_hand.indexOf(card) @@ -3370,13 +3379,8 @@ function select_card(card) { find_card = game.democrat_hand.indexOf(card) game.democrat_hand.splice(find_card, 1) } - game.state = 'play_card' -} -function finish_select_card() { - if (!scoring_cards.includes(game.played_card)) { - game.available_ops = get_card_ops(game.played_card) - if (game.state !== 'stasi_play_ceh') - log(`Played C${game.played_card}.`) + if (!game.strategy_discard.includes(card)) { + game.strategy_discard.push(card) } } @@ -3811,13 +3815,14 @@ function end_round() { } // Check if the card needs to be discarded. + /* let discard_check = [...game.strategy_removed, ...game.persistent_events] if (!discard_check.includes(game.played_card) && game.played_card > 0) { game.strategy_discard.push(game.played_card) - } + } */ // Reset - game.played_card = 0 + delete game.played_card delete game.temp delete game.vm_event delete game.phase @@ -4191,16 +4196,7 @@ function discard(card) { function silent_discard(card) { let find_card if (!game.is_pwr_struggle) { - if (game.active === COM) { - find_card = game.communist_hand.indexOf(card) - game.communist_hand.splice(find_card, 1) - } else { - find_card = game.democrat_hand.indexOf(card) - game.democrat_hand.splice(find_card, 1) - } - if (!game.strategy_discard.includes(card)) { - game.strategy_discard.push(card) - } + remove_from_hand(card) } else if (game.is_pwr_struggle) { if (game.active === COM) { find_card = game.com_pwr_hand.indexOf(card) |