diff options
-rw-r--r-- | rules.js | 55 |
1 files changed, 27 insertions, 28 deletions
@@ -336,7 +336,7 @@ function versailles_objective_space() { function discard_card(c) { array_remove_item(player_hand(), c) - game.discard = c + game.discard.push(c) } function recycle_card(c) { @@ -344,6 +344,10 @@ function recycle_card(c) { game.strategy_deck.unshift(c) } +function remove_card(c) { + array_remove_item(player_hand(), c) +} + function add_political_vp(side, amount) { if (side === COMMUNE) { if (amount > 0) @@ -1081,6 +1085,13 @@ function player_final_crisis_card() { return game.blue_final } +function top_discard() { + let n = game.discard.length + if (n > 0) + return game.discard[n-1] + return 0 +} + states.strategy_phase = { inactive: "play a card", prompt() { @@ -1094,9 +1105,9 @@ states.strategy_phase = { if (final > 0) gen_action_card(final) - if (game.discard > 0 && !is_neutral_card(game.discard)) - if (can_play_event(game.discard)) - gen_action_card(game.discard) + if (top_discard() > 0 && !is_neutral_card(top_discard())) + if (can_play_event(top_discard())) + gen_action_card(top_discard()) } }, @@ -1105,7 +1116,7 @@ states.strategy_phase = { game.what = c if (c === 17 || c === 34) { game.state = "play_final_discard" - } else if (c === game.discard) { + } else if (c === top_discard()) { game.state = "play_discard" } else { game.state = "play_card" @@ -1161,7 +1172,7 @@ states.play_card = { if (game.censorship) recycle_card(game.what) else - discard_card(game.what) + remove_card(game.what) if (game.active === COMMUNE) game.state = "advance_revolutionary_momentum" else @@ -3116,14 +3127,10 @@ states.pius_ix = { function init_karl_marx() { clear_undo() - // Draw cards into hand in case a reshuffle is triggered. - game.red_hand.push(draw_strategy_card()) - game.red_hand.push(draw_strategy_card()) - game.red_hand.push(draw_strategy_card()) game.vm.cards = [ - game.red_hand.pop(), - game.red_hand.pop(), - game.red_hand.pop(), + draw_strategy_card(), + draw_strategy_card(), + draw_strategy_card(), ] } @@ -3139,7 +3146,7 @@ states.karl_marx_discard = { push_undo() log("Discarded C" + c + ".") array_remove_item(game.vm.cards, c) - game.discard = c + game.discard.push(c) if (game.vm.cards.length === 1) game.state = "karl_marx_play" }, @@ -3160,13 +3167,13 @@ states.karl_marx_play = { let c = game.vm.cards[0] push_undo() log("Played C" + c + ".") - game.discard = c + game.discard.push(c) goto_play_event(c) }, card(c) { push_undo() log("Discarded C" + c + ".") - game.discard = c + game.discard.push(c) vm_next() }, } @@ -3302,20 +3309,12 @@ exports.setup = function (seed, scenario, options) { return game } -function reshuffle_strategy_deck() { - game.discard = 0 - game.strategy_deck = [] - for (let c = 1; c <= 41; ++c) - if (c !== 17 && c !== 34) - if (!game.red_hand.includes(c) && !game.blue_hand.includes(c)) - game.strategy_deck.push(c) - shuffle(game.strategy_deck) -} - function draw_strategy_card() { if (game.strategy_deck.length === 0) { log("Reshuffled.") - reshuffle_strategy_deck() + game.strategy_deck = game.discard + game.discard = [] + shuffle(game.strategy_deck) } return game.strategy_deck.pop() } @@ -3350,7 +3349,7 @@ exports.view = function (state, player) { pieces: game.pieces, - discard: game.discard, + discard: top_discard(), hand: 0, final: 0, set_aside: 0, |