diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-18 23:26:36 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-18 23:26:36 +0200 |
commit | ab56fd537897949fed6299a3964687ab5ac01e6a (patch) | |
tree | fee48ed2505d981511000e77a868d5204ed723ad /rules.ts | |
parent | caee1e3e0776797f8c59fa0fd60ae6505bafca98 (diff) | |
download | plantagenet-ab56fd537897949fed6299a3964687ab5ac01e6a.tar.gz |
Fix Bloody thou art before Death Check events.
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 85 |
1 files changed, 56 insertions, 29 deletions
@@ -111,7 +111,6 @@ interface Game { }, flags: { - bloody: 0 | 1, burgundians: 0 | 1, first_action: 0 | 1, first_march_highway: 0 | 1, @@ -7154,21 +7153,23 @@ states.battle_spoils = { function goto_death_or_disband() { remove_battle_capability_troops() - if (game.battle.loser === LANCASTER && lord_has_capability(LORD_RICHARD_III, AOW_YORK_BLOODY_THOU_ART) && get_lord_locale(LORD_RICHARD_III) === game.battle.where) - game.flags.bloody = 1 - else - game.flags.bloody = 0 - - if (has_defeated_lords()) - game.state = "death_check" - else + if (has_defeated_lords()) { + if (is_bloody_thou_art_triggered()) + game.state = "bloody_thou_art" + else + game.state = "death_check" + } else { end_death_or_disband() + } } function end_death_or_disband() { set_active_enemy() if (has_defeated_lords()) { - game.state = "death_check" + if (is_bloody_thou_art_triggered()) + game.state = "bloody_thou_art" + else + game.state = "death_check" } else { goto_battle_aftermath() } @@ -7236,24 +7237,15 @@ states.death_check = { let threshold = 2 let modifier = 0 - // CAPABILITY: BLOODY THOU ART, BLOODY WILL BE THE END - if (is_lancaster_lord(lord) && game.flags.bloody === 1) { - logcap(AOW_YORK_BLOODY_THOU_ART) - disband_lord(lord, true) - set_delete(game.battle.fled, lord) - set_delete(game.battle.routed, lord) - } - else { - let roll = roll_die() - if (set_has(game.battle.fled, lord)) - modifier = -2 + let roll = roll_die() + if (set_has(game.battle.fled, lord)) + modifier = -2 - let success = threshold >= roll + modifier - log(`Lord ${lord_name[lord]} ${success ? "Survived" : "Died"}: (${range(2)}) ${success ? HIT[roll] : MISS[roll]} ${modifier < 0 ? "(-2 Fled)" : ""}`) - disband_lord(lord, !success) - set_delete(game.battle.fled, lord) - set_delete(game.battle.routed, lord) - } + let success = threshold >= roll + modifier + log(`Lord ${lord_name[lord]} ${success ? "Survived" : "Died"}: (${range(2)}) ${success ? HIT[roll] : MISS[roll]} ${modifier < 0 ? "(-2 Fled)" : ""}`) + disband_lord(lord, !success) + set_delete(game.battle.fled, lord) + set_delete(game.battle.routed, lord) }, done() { end_death_or_disband() @@ -7261,6 +7253,43 @@ states.death_check = { card: action_held_event_at_death_check, } +// === DEATH CHECK CAPABILITY: BLOODY THOU ART === + +function is_bloody_thou_art_triggered() { + return ( + game.active === LANCASTER && + game.battle.loser === LANCASTER && + lord_has_capability(LORD_RICHARD_III, AOW_YORK_BLOODY_THOU_ART) && + get_lord_locale(LORD_RICHARD_III) === game.battle.where + ) +} + +states.bloody_thou_art = { + inactive: "Bloody thou art", + prompt() { + view.prompt = "Bloody thou art: All Routed Lancastrian Lords Die." + + let done = true + for (let lord of game.battle.routed) { + if (is_friendly_lord(lord)) { + gen_action_lord(lord) + done = false + } + } + + if (done) + view.actions.done = 1 + }, + lord(lord) { + logcap(AOW_YORK_BLOODY_THOU_ART) + disband_lord(lord, true) + set_delete(game.battle.routed, lord) + }, + done() { + game.state = "death_check" + }, +} + // === DEATH CHECK EVENT: ESCAPE SHIP === function can_play_escape_ship() { @@ -7457,7 +7486,6 @@ function goto_battle_aftermath() { // Recovery spend_all_actions() delete game.battle - game.flags.bloody = 0 end_march() } @@ -8337,7 +8365,6 @@ exports.setup = function (seed, scenario, options) { }, flags: { - bloody: 0, burgundians: 0, first_action: 0, first_march_highway: 0, |