summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js108
1 files changed, 92 insertions, 16 deletions
diff --git a/rules.js b/rules.js
index 0c3d23c..99aac6c 100644
--- a/rules.js
+++ b/rules.js
@@ -1475,18 +1475,6 @@ function end_strategy_card() {
}
}
- while (game.b_draw > 0) {
- log("British replacement card.")
- set_add(game.b_hand, deal_card())
- game.b_draw--
- }
-
- while (game.a_draw > 0) {
- log("American replacement card.")
- set_add(game.a_hand, deal_card())
- game.a_draw--
- }
-
game.state = "end_strategy_card"
return true
}
@@ -1521,17 +1509,41 @@ function next_strategy_card() {
reset_moved_cu()
// Tournament rule for DoI and Franklin events
- if (CARDS[game.card].tournament && game.active === P_BRITAIN) {
- game.card = 0
+ if (game.card > 0 && CARDS[game.card].tournament && game.active === P_BRITAIN) {
log_br()
log("Tournament Rule!")
log("British replacement card.")
- set_add(game.b_hand, deal_card())
- goto_strategy_phase(game.active)
+ set_add(game.b_hand, game.card = deal_card())
+ game.state = "draw_replacement_card_tournament"
return
}
game.card = 0
+
+ if (game.active === P_BRITAIN) {
+ if (draw_british_replacement()) {
+ game.state = "draw_replacement_card"
+ return
+ }
+ if (draw_american_replacement()) {
+ game.active = P_AMERICA
+ game.state = "draw_replacement_card_opponent"
+ return
+ }
+ }
+
+ if (game.active === P_AMERICA) {
+ if (draw_american_replacement()) {
+ game.state = "draw_replacement_card"
+ return
+ }
+ if (draw_british_replacement()) {
+ game.active = P_BRITAIN
+ game.state = "draw_replacement_card_opponent"
+ return
+ }
+ }
+
goto_strategy_phase(ENEMY[game.active])
}
@@ -1547,6 +1559,70 @@ function clear_queue() {
game.a_queue = 0
}
+/* REPLACEMENT CARDS AFTER BATTLE EVENTS */
+
+function draw_british_replacement() {
+ if (game.b_draw > 0) {
+ log("British replacement card.")
+ set_add(game.b_hand, game.card = deal_card())
+ game.b_draw--
+ return true
+ }
+ return false
+}
+
+function draw_american_replacement() {
+ if (game.a_draw > 0) {
+ log("American replacement card.")
+ set_add(game.a_hand, game.card = deal_card())
+ game.a_draw--
+ return true
+ }
+ return false
+}
+
+states.draw_replacement_card = {
+ inactive: "to draw a replacement card",
+ prompt() {
+ view.prompt = "You drew " + card_name(game.card) + "."
+ view.selected_card = game.card
+ view.actions.next = 1
+ },
+ next() {
+ clear_undo()
+ game.card = 0
+ next_strategy_card()
+ },
+}
+
+states.draw_replacement_card_opponent = {
+ inactive: "to draw a replacement card",
+ prompt() {
+ view.prompt = "You drew " + card_name(game.card) + "."
+ view.selected_card = game.card
+ view.actions.next = 1
+ },
+ next() {
+ clear_undo()
+ game.active = ENEMY[game.active]
+ game.card = 0
+ next_strategy_card()
+ },
+}
+
+states.draw_replacement_card_tournament = {
+ inactive: "to draw a replacement card",
+ prompt() {
+ view.prompt = "You drew " + card_name(game.card) + "."
+ view.selected_card = game.card
+ view.actions.next = 1
+ },
+ next() {
+ clear_undo()
+ goto_strategy_phase(game.active)
+ },
+}
+
/* DISCARD EVENT CARD FOR PC ACTION */
states.discard_event_pc_action = {