From 010feb8744520b71de1b84120d4f626bbc0c7166 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 3 Jul 2023 23:52:24 +0200 Subject: Auto-play Princes Senatus and Frumentarii at end of Take Actions. --- rules.js | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/rules.js b/rules.js index c82f25c..f950ad5 100644 --- a/rules.js +++ b/rules.js @@ -7,19 +7,14 @@ TODO [ ] display of general+castra stacked with militia+castra [ ] todo: battle twice with militia (remove mbattled?) -[ ] emperor -[ ] expansion cards - -Frumentarii -Demagogue -Spiculum - */ var game var view const states = {} +const AUTO_PLAY_EVENTS = true + const P1 = "Red" const P2 = "Blue" const P3 = "Yellow" @@ -1156,6 +1151,13 @@ function gen_card_event(event) { gen_action_card(c) } +function find_unused_card_event(event) { + for (let c = event[0]; c <= event[1]; ++c) + if (set_has(game.played, c) && !set_has(game.used, c)) + return c + return -1 +} + function has_card_event(event) { for (let c = event[0]; c <= event[1]; ++c) if (set_has(game.played, c) && !set_has(game.used, c)) @@ -1908,6 +1910,10 @@ states.take_actions = { game.selected_governor = -1 game.selected_general = -1 game.selected_militia = -1 + if (AUTO_PLAY_EVENTS) { + auto_play_princeps_senatus() + auto_play_frumentarii() + } goto_support_check() }, @@ -3157,6 +3163,14 @@ states.pretender_breakaway = { // CARD: Princeps Senatus +function auto_play_princeps_senatus() { + let c = find_unused_card_event(CARD_S2X) + if (c >= 0) { + set_add(game.used, c) + play_princeps_senatus() + } +} + function can_play_princeps_senatus() { return !used_card_event(CARD_S2X) } @@ -3299,6 +3313,14 @@ states.force_march = { // CARD: Frumentarii +function auto_play_frumentarii() { + let c = find_unused_card_event(CARD_S3X) + if (c >= 0) { + set_add(game.used, c) + play_frumentarii() + } +} + function can_play_frumentarii() { return !used_card_event(CARD_S3X) } @@ -4638,11 +4660,11 @@ function goto_buy_trash_cards() { game.pp = count_political_points() - log_h3(game.pp + " Political Points") + log_h3(game.pp + " Political Points.") if (used_card_event(CARD_S2X)) { let n = Math.min(2, game.sip) if (n > 0) { - logi("+" + n + " for Princeps Senatus") + log("+" + n + " for Princeps Senatus.") game.pp += n } } -- cgit v1.2.3