diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-12-29 13:51:23 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:38 +0100 |
commit | fe861a54da448078aac87288a1e8929a8bc2c5fb (patch) | |
tree | 1d5184abf235a59a4a9c6aab74eed9e1dcd4188d | |
parent | 70e483427c41dd44ab150d25e47c1f80a8c494dd (diff) | |
download | nevsky-fe861a54da448078aac87288a1e8929a8bc2c5fb.tar.gz |
Event discard helper.
-rw-r--r-- | rules.js | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -1470,6 +1470,18 @@ function discard_card(c) { set_add(game.deck2, c) } +function discard_events(when) { + for (let i = 0; i < game.events.length; ) { + let c = game.events[i] + if (data.cards[c].when === when) { + array_remove(game.events, i) + discard_card(c) + } else { + ++i + } + } +} + exports.setup = function (seed, scenario, options) { game = { seed, @@ -2606,15 +2618,7 @@ function end_levy_call_to_arms() { function goto_levy_discard_events() { // Discard "This Levy" events from play. - for (let i = 0; i < game.events.length; ) { - let c = game.events[i] - if (data.cards[c].when === "this_levy") { - array_remove(game.events, i) - discard_card(c) - } else { - ++i - } - } + discard_events("this_levy") set_active(P1) goto_capability_discard() @@ -7480,15 +7484,7 @@ function goto_reset() { } // Discard "This Campaign" events from play. - for (let i = 0; i < game.events.length; ) { - let c = game.events[i] - if (data.cards[c].when === "this_campaign") { - array_remove(game.events, i) - discard_card(c) - } else { - ++i - } - } + discard_events("this_campaign") goto_advance_campaign() } |