diff options
author | Frans Bongers <fransbongers@macbookpro.home> | 2025-03-25 11:52:26 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@macbookpro.home> | 2025-03-25 11:52:26 +0100 |
commit | 5aef76ee121090ead684540b9889fd8e10852c82 (patch) | |
tree | 568a5a4bf69f7c68d334d67247432df8b5b55ed2 | |
parent | 57c7b2292f44712b27efebff4401be22cead0437 (diff) | |
download | land-and-freedom-5aef76ee121090ead684540b9889fd8e10852c82.tar.gz |
auto draw from bag of glory
-rw-r--r-- | rules.js | 29 | ||||
-rw-r--r-- | rules.ts | 40 |
2 files changed, 42 insertions, 27 deletions
@@ -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); }, }; @@ -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); }, |