diff options
-rw-r--r-- | rules.js | 43 |
1 files changed, 33 insertions, 10 deletions
@@ -1095,6 +1095,13 @@ function flip_discard_to_available() { game.discard[game.current] = [] } +function flip_discard_to_available_if_empty() { + if (game.draw[game.current].length === 0) { + log("Put discard in available.") + flip_discard_to_available() + } +} + function eliminate_military_emperor(id) { if (is_emperor_player()) game.combat.own_military_emperor_died = 1 @@ -1372,8 +1379,10 @@ function goto_pax_deorum() { function resume_pax_deorum() { game.state = "pax_deorum" - if (game.draw[game.current].length === 0) + if (game.draw[game.current].length === 0) { + log(PLAYER_NAME[game.current] + " put discard in available.") flip_discard_to_available() + } } states.pax_deorum = { @@ -1815,6 +1824,7 @@ function goto_take_actions() { game.frumentarii &= ~(1 << game.current) game.count = 2 game.state = "frumentarii" + resume_frumentarii() } } @@ -3562,6 +3572,10 @@ function play_frumentarii() { game.frumentarii |= (1 << game.current) } +function resume_frumentarii() { + flip_discard_to_available_if_empty() +} + states.frumentarii = { inactive: "Frumentarii", prompt() { @@ -3576,10 +3590,10 @@ states.frumentarii = { let draw = current_draw() set_delete(draw, c) set_add(hand, c) - if (draw.length === 0) - flip_discard_to_available() if (--game.count === 0) resume_take_actions() + else + resume_frumentarii() }, } @@ -5162,9 +5176,21 @@ function goto_refill_hand() { end_refill_hand() return } - if (current_draw().length === 0) - flip_discard_to_available() game.state = "refill_hand" + resume_refill_hand() +} + +function get_refill_hand_size() { + if (game.frumentarii & (1 << game.current)) + return 3 + return 5 +} + +function resume_refill_hand() { + let n = get_refill_hand_size() + let hand = current_hand() + if (hand.length < n) + flip_discard_to_available_if_empty() } states.refill_hand = { @@ -5172,9 +5198,7 @@ states.refill_hand = { prompt() { let hand = current_hand() let draw = current_draw() - let n = 5 - if (game.frumentarii & (1 << game.current)) - n = 3 + let n = get_refill_hand_size() if (hand.length < n && draw.length > 0) { prompt("End of Turn: Draw cards.") for (let c of draw) @@ -5190,8 +5214,7 @@ states.refill_hand = { let draw = current_draw() set_delete(draw, c) set_add(hand, c) - if (draw.length === 0) - flip_discard_to_available() + resume_refill_hand() }, end_turn() { end_refill_hand() |