From 5aef76ee121090ead684540b9889fd8e10852c82 Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Tue, 25 Mar 2025 11:52:26 +0100 Subject: auto draw from bag of glory --- rules.js | 29 ++++++++++++++++++----------- rules.ts | 40 ++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/rules.js b/rules.js index b1714dc..e44b8e0 100644 --- a/rules.js +++ b/rules.js @@ -1213,25 +1213,32 @@ states.draw_card = { resolve_active_and_proceed(true); }, }; +function draw_glory_from_bag() { + const index = random(game.bag_of_glory.length); + const faction = game.bag_of_glory[index]; + game.glory.push(faction); + game.glory_current_year = game.glory_current_year = [ + false, + false, + false, + ]; + game.glory_current_year[faction] = true; + array_remove(game.bag_of_glory, index); + logi(`Pulled T${faction} from the Bag`); +} states.draw_glory = { inactive: 'draw from the Bag of Glory', + auto_resolve() { + draw_glory_from_bag(); + return true; + }, prompt() { gen_spend_hero_points(); view.prompt = 'Draw from the Bag of Glory.'; gen_action('draw_glory'); }, draw_glory() { - const index = random(game.bag_of_glory.length); - const faction = game.bag_of_glory[index]; - game.glory.push(faction); - game.glory_current_year = game.glory_current_year = [ - false, - false, - false, - ]; - game.glory_current_year[faction] = true; - array_remove(game.bag_of_glory, index); - logi(`Pulled T${faction} from the Bag`); + draw_glory_from_bag(); resolve_active_and_proceed(true); }, }; diff --git a/rules.ts b/rules.ts index 2e386a1..bb64184 100644 --- a/rules.ts +++ b/rules.ts @@ -1509,30 +1509,38 @@ states.draw_card = { }, }; +function draw_glory_from_bag() { + const index = random(game.bag_of_glory.length); + const faction = game.bag_of_glory[index]; + + game.glory.push(faction); + + game.glory_current_year = game.glory_current_year = [ + false, + false, + false, + ]; + + game.glory_current_year[faction] = true; + + array_remove(game.bag_of_glory, index); + + logi(`Pulled T${faction} from the Bag`); +} + states.draw_glory = { inactive: 'draw from the Bag of Glory', + auto_resolve() { + draw_glory_from_bag(); + return true; + }, prompt() { gen_spend_hero_points(); view.prompt = 'Draw from the Bag of Glory.'; gen_action('draw_glory'); }, draw_glory() { - const index = random(game.bag_of_glory.length); - const faction = game.bag_of_glory[index]; - - game.glory.push(faction); - - game.glory_current_year = game.glory_current_year = [ - false, - false, - false, - ]; - - game.glory_current_year[faction] = true; - - array_remove(game.bag_of_glory, index); - - logi(`Pulled T${faction} from the Bag`); + draw_glory_from_bag(); resolve_active_and_proceed(true); }, -- cgit v1.2.3