summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-25 15:56:46 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-25 15:56:46 +0100
commit4cf5201421f883984b414778dd8664410305f9ea (patch)
tree16e8ac7524218948256168b0166664b4952e2bf5 /rules.js
parentece5503c7c490e3f717531b85cd68a27fcf85591 (diff)
downloadvotes-for-women-4cf5201421f883984b414778dd8664410305f9ea.tar.gz
opponent discard 2 cards at random and then draw 2 cards
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js35
1 files changed, 31 insertions, 4 deletions
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 ],
]