diff options
-rw-r--r-- | events.txt | 4 | ||||
-rw-r--r-- | play.html | 7 | ||||
-rw-r--r-- | play.js | 10 | ||||
-rw-r--r-- | rules.js | 167 |
4 files changed, 167 insertions, 21 deletions
@@ -559,7 +559,7 @@ CARD 107 - Opposition Research CARD 108 - Change In Plans # Look at your opponent’s hand. Your opponent must discard 1 card of your choice that does not have a :yellow_campaigner / :purple_campaigner / :red_campaigner on it. Your opponent then draws 1 replacement card from their Draw Deck. - todo + show_opponents_hand_discard_1_draw_1 CARD 109 - Bellwether State # Select one state and remove any :red_cube and add 4 :purple_or_yellow_cube or remove any :purple_or_yellow_cube and add 4 :red_cube. @@ -595,7 +595,7 @@ CARD 112 - Regional Focus CARD 113 - Eye on the Future # Playable if it is Turn 5 or Turn 6. Look through your Draw Deck and select 1 card and play for its event immediately. Then reshuffle your Draw Deck. - todo + select_1_card_from_draw_deck_play_event_shuffle CARD 114 - Transportation # Move all of your :purple_campaigner and :yellow_campaigner OR :red_campaigner to any region(s) without playing any :button and then take a Campaigning action. @@ -1092,6 +1092,13 @@ c5 3 13 7 17 8 8 2 9 3 11 12 1 5 5 12 8 16 5 8 5 8 3 22 l-3 14 -30 -1 c-35 </div> <div class="panel_grid"> + <div id="set_aside_panel" class="panel hide"> + <div id="set_aside_header" class="panel_header">Set-aside cards</div> + <div id="set_aside" class="panel_body"></div> + </div> + </div> + + <div class="panel_grid"> <div id="support_claimed_panel" class="panel"> <div id="support_claimed_header" class="panel_header">Suffragist Claimed</div> <div id="support_claimed" class="panel_body"></div> @@ -668,6 +668,7 @@ function on_update() { // eslint-disable-line no-unused-vars } document.getElementById("hand").replaceChildren() + document.getElementById("set_aside").replaceChildren() document.getElementById("support_claimed").replaceChildren() document.getElementById("support_discard").replaceChildren() document.getElementById("opposition_claimed").replaceChildren() @@ -684,6 +685,14 @@ function on_update() { // eslint-disable-line no-unused-vars document.getElementById("hand_panel").classList.add("hide") } + if (view.set_aside.length) { + document.getElementById("set_aside_panel").classList.remove("hide") + for (let c of view.set_aside) + document.getElementById("set_aside").appendChild(ui.cards[c]) + } else { + document.getElementById("set_aside_panel").classList.add("hide") + } + for (let c of view.support_claimed) document.getElementById("support_claimed").appendChild(ui.cards[c]) for (let c of view.support_discard) @@ -752,7 +761,6 @@ function on_update() { // eslint-disable-line no-unused-vars let state_cubes = [] for (let c = 0; c < purple_cubes(i); ++c) { e = ui.cubes[cube_idx++] - // TODO track both state and color e.my_us_state = i e.my_cube = PURPLE e.classList.add("purple") @@ -112,10 +112,17 @@ function draw_card(deck) { function player_hand() { if (game.active === SUF) { return game.support_hand - } else if (game.active === OPP) { + } else { + return game.opposition_hand + } +} + +function opponent_hand() { + if (game.active === SUF) { return game.opposition_hand + } else { + return game.support_hand } - return [] } function player_buttons() { @@ -150,6 +157,14 @@ function player_deck() { } } +function opponent_deck() { + if (game.active === SUF) { + return game.opposition_deck + } else { + return game.support_deck + } +} + function player_discard() { if (game.active === SUF) { return game.support_discard @@ -162,6 +177,32 @@ function is_player_claimed_card(c) { return player_claimed().includes(c) } +function player_set_aside() { + if (game.active === SUF) { + return game.support_set_aside + } else { + return game.opposition_set_aside + } +} + +function set_aside_player_hand() { + let aside = player_set_aside() + let hand = player_hand() + set_clear(aside) + for (let c of hand) + aside.push(c) + set_clear(hand) +} + +function restore_player_hand() { + let aside = player_set_aside() + let hand = player_hand() + set_clear(hand) + for (let c of aside) + hand.push(c) + set_clear(aside) +} + // #endregion // #region US_STATES & REGIONS FUNCTIONS @@ -526,12 +567,14 @@ exports.setup = function (seed, _scenario, _options) { support_deck: [], support_discard: [], support_hand: [], + support_set_aside: [], support_claimed: [], support_buttons: 0, opposition_deck: [], opposition_discard: [], opposition_hand: [], + opposition_set_aside: [], opposition_claimed: [], opposition_buttons: 0, @@ -636,6 +679,7 @@ exports.VIEW_SCHEMA = { out_of_play: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}}, hand: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}}, + set_aside: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}}, selected_cards: {type: "array", items: {type: "integer", minimum: 1, maximum: 128}}, }, @@ -692,14 +736,17 @@ exports.view = function(state, player) { out_of_play: game.out_of_play, hand: [], + set_aside: [], selected_cards: [], } if (player === SUF) { view.hand = game.support_hand + view.set_aside = game.support_set_aside view.selected_cards = game.selected_cards } else if (player === OPP) { view.hand = game.opposition_hand + view.set_aside = game.opposition_set_aside view.selected_cards = game.selected_cards } @@ -1107,7 +1154,7 @@ function discard_persistent_card(cards, c) { log(`C${c} discarded.`) array_remove_item(cards, c) - // TODO does it matter where we discard them? + // XXX does it matter where we discard them? // I see no value in having multiple discard piles. if (is_support_card(c)) { game.support_discard.push(c) @@ -1431,8 +1478,7 @@ function campaigner_color(c) { function goto_campaigning_add_cubes(campaigner, die) { game.selected_campaigner = campaigner set_add(game.campaigning.assigned, campaigner) - // TODO die type & color - log(`Assigned B${die} to ${COLOR_CODE[campaigner_color(campaigner)]}R in R${campaigner_region(campaigner)}.`) + log(`Assigned ${DICE_COLOR[game.dice]}${die} to ${COLOR_CODE[campaigner_color(campaigner)]}R in R${campaigner_region(campaigner)}.`) game.campaigning.count = die game.campaigning.added = 0 game.campaigning.moved = false @@ -2091,12 +2137,6 @@ function vm_campaigning_action() { } } -function vm_todo() { - // TODO - log("TODO") - vm_next() -} - function vm_counter_strat() { game.state = "vm_counter_strat" } @@ -2131,6 +2171,28 @@ function vm_opponent_discard_2_random_draw_2() { game.state = "vm_opponent_discard_2_random_draw_2" } +function vm_show_opponents_hand_discard_1_draw_1() { + clear_undo() + set_aside_player_hand() + + for (let c of opponent_hand()) + player_hand().push(c) + + log(`${game.active} looked at ${opponent_name()}'s Hand.`) + game.state = "vm_show_opponents_hand_discard_1_draw_1" +} + +function vm_select_1_card_from_draw_deck_play_event_shuffle() { + clear_undo() + set_aside_player_hand() + + for (let c of player_deck()) + player_hand().push(c) + + log(`${game.active} looked at their Draw Deck.`) + game.state = "vm_select_1_card_from_draw_deck_play_event_shuffle" +} + // #endregion // #region EVENT STATES @@ -2633,8 +2695,7 @@ states.vm_select_us_state = { gen_action_us_state(s) } } else { - // TODO show state name - event_prompt(`Selected S${game.vm.selected_us_state}.`) + event_prompt(`Selected ${US_STATES[game.vm.selected_us_state].name}.`) gen_action("done") } }, @@ -2725,7 +2786,7 @@ states.vm_draw_2_play_1_event = { play_card_event(c) }, skip() { - log("None of the drawn cards could be played for their event.") + log("None of the cards could be played for their event.") for (let c of game.vm.draw) { discard_card_from_hand(c) } @@ -2754,7 +2815,7 @@ states.vm_place_any_on_top_of_draw = { prompt() { let can_play = false if (game.vm.play_one && !game.selected_cards.length) { - event_prompt(`Select which card to play as event.`) + event_prompt("Select which card to play as event.") for (let c of game.vm.draw) { if (can_play_event(c)) { gen_action_card(c) @@ -2762,7 +2823,7 @@ states.vm_place_any_on_top_of_draw = { } } } else { - event_prompt(`Select which cards to put on top of your Draw Deck.`) + event_prompt("Select which cards to put on top of your Draw Deck.") for (let c of game.vm.draw) { if (!game.selected_cards.includes(c)) gen_action_card(c) @@ -2834,6 +2895,76 @@ states.vm_opponent_discard_2_random_draw_2 = { } } +const CAMPAIGNER_CARDS = [ + 1, 19, 36, 53, 71, 84, 108, 114 +] + +states.vm_show_opponents_hand_discard_1_draw_1 = { + inactive: "discard one card from of your hand.", + prompt() { + event_prompt("Select one card from your opponent's Hand to discard.") + let can_discard = false + for (let c of player_hand()) { + // exclude cards with campaigners on them + if (!CAMPAIGNER_CARDS.includes(c)) { + gen_action_card(c) + can_discard = true + } + } + + if (!can_discard) + gen_action("skip") + }, + card(c) { + restore_player_hand() + log(`Discarded C${c}.`) + array_remove_item(opponent_hand(), c) + opponent_hand().push(draw_card(opponent_deck())) + log(`${opponent_name()} drew 1 card.`) + vm_next() + }, + skip() { + restore_player_hand() + log("None of the Opponent's cards could be discarded.") + vm_next() + } +} + +states.vm_select_1_card_from_draw_deck_play_event_shuffle = { + inactive: "play one card from their draw deck as event.", + prompt() { + event_prompt("Select one card from your Draw Deck and play for its event.") + let can_play = false + for (let c of player_hand()) { + if (can_play_event(c)) { + gen_action_card(c) + can_play = true + } + } + + if (!can_play) + gen_action("skip") + }, + card(c) { + restore_player_hand() + log(`Selected C${c}.`) + player_hand().push(c) + array_remove_item(player_deck(), c) + log(`Shuffled ${game.active}'s Deck.`) + shuffle(player_deck()) + + end_play_card(game.played_card) + play_card_event(c) + }, + skip() { + restore_player_hand() + log("None of the cards could be played for their event.") + log(`Shuffled ${game.active}'s Deck.`) + shuffle(player_deck()) + vm_next() + } +} + // #endregion // #region LOGGING @@ -3849,7 +3980,7 @@ CODE[107] = [ // Opposition Research ] CODE[108] = [ // Change In Plans - [ vm_todo ], + [ vm_show_opponents_hand_discard_1_draw_1 ], [ vm_return ], ] @@ -3890,7 +4021,7 @@ CODE[112] = [ // Regional Focus ] CODE[113] = [ // Eye on the Future - [ vm_todo ], + [ vm_select_1_card_from_draw_deck_play_event_shuffle ], [ vm_return ], ] |