From 4cf5201421f883984b414778dd8664410305f9ea Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Sat, 25 Nov 2023 15:56:46 +0100 Subject: opponent discard 2 cards at random and then draw 2 cards --- events.txt | 2 +- rules.js | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/events.txt b/events.txt index 8c97a4e..50ebc38 100644 --- a/events.txt +++ b/events.txt @@ -514,7 +514,7 @@ CARD 98 - Voter Suppression CARD 99 - Anti-Suffrage Riots # The Suffragist player must discard 2 cards from their hand at random and then draw 2 cards from the Suffragist Draw Deck. - support_discard_2_random_draw_2 + opponent_discard_2_random_draw_2 CARD 100 - American Constitutional League # Spend 4 :button to select, and place in front of you, 1 available Strategy card. diff --git a/rules.js b/rules.js index 5970708..32a4ec7 100644 --- a/rules.js +++ b/rules.js @@ -2123,9 +2123,10 @@ function vm_draw_6_play_1_place_any_on_top_of_draw() { goto_vm_place_any_on_top_of_draw() } -function vm_support_discard_2_random_draw_2() { - log("TODO support_discard_2_random_draw_2") - vm_next() +function vm_opponent_discard_2_random_draw_2() { + clear_undo() + next_player() + game.state = "vm_opponent_discard_2_random_draw_2" } // #endregion @@ -2803,6 +2804,31 @@ states.vm_place_any_on_top_of_draw = { } } +states.vm_opponent_discard_2_random_draw_2 = { + inactive: "discard 2 cards at random and then draw 2 cards.", + prompt() { + event_prompt("You must discard 2 cards from Hand at random and then draw 2 cards.") + gen_action("next") + }, + next() { + clear_undo() + let first_two = shuffle(object_copy(player_hand())).slice(0, 2) + for (let c of first_two) { + discard_card_from_hand(c) + log(`${game.active} discarded C${c}.`) + } + // XXX if we could discard less than two, should we also draw less than two? + let draw_count = Math.min(first_two.length, 2) + for (let i = 0; i < draw_count; ++i) { + let card = draw_card(player_deck()) + player_hand().push(card) + } + log(`${game.active} drew ${draw_count} cards.`) + next_player() + vm_next() + } +} + // #endregion // #region LOGGING @@ -2898,6 +2924,7 @@ function shuffle(list) { list[j] = list[i] list[i] = tmp } + return list } // Fast deep copy for objects without cycles @@ -3765,7 +3792,7 @@ CODE[98] = [ // Voter Suppression ] CODE[99] = [ // Anti-Suffrage Riots - [ vm_support_discard_2_random_draw_2 ], + [ vm_opponent_discard_2_random_draw_2 ], [ vm_return ], ] -- cgit v1.2.3