diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-03 23:52:24 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-07 19:05:52 +0200 |
commit | 010feb8744520b71de1b84120d4f626bbc0c7166 (patch) | |
tree | 8753207abbc9a6ab430bbd2694149af024941172 /rules.js | |
parent | 3d5e4a5144ca8d522661087609523c9cfbc348ce (diff) | |
download | time-of-crisis-010feb8744520b71de1b84120d4f626bbc0c7166.tar.gz |
Auto-play Princes Senatus and Frumentarii at end of Take Actions.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 40 |
1 files changed, 31 insertions, 9 deletions
@@ -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 } } |