diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-18 15:24:52 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-18 15:24:52 +0200 |
commit | e15c192ce9f8337bbc5497a2ca0f6e0eb34ee746 (patch) | |
tree | e0e35971e09dc679ab33ff2155255cd5caf0ab54 /rules.ts | |
parent | 78c940d347968b34f51e4c138d94fb752fd8ecc6 (diff) | |
download | plantagenet-e15c192ce9f8337bbc5497a2ca0f6e0eb34ee746.tar.gz |
Fix "Flank Attack".
Simplify prompts. Swap attacker if event is in play.
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 57 |
1 files changed, 20 insertions, 37 deletions
@@ -129,7 +129,6 @@ interface Game { succession: 0 | 1, supply_depot: 0 | 1, surprise_landing: 0 | 1, - swap_battle_attacker: 0 | 1, warden_of_the_marches: 0 | 1, }, @@ -4695,43 +4694,18 @@ function end_intercept() { goto_kings_parley() } -function can_play_held_event_at_intercept(c: Card) { - switch (c) { - case EVENT_LANCASTER_FLANK_ATTACK: - return can_play_flank_attack() - case EVENT_YORK_FLANK_ATTACK: - return can_play_flank_attack() - } - return false -} - -function prompt_held_event_intercept() { - for (let c of current_hand()) - if (can_play_held_event_at_intercept(c)) - gen_action_card(c) -} - -function action_held_event_at_intercept(c: Card) { - push_undo() - play_held_event(c) - switch (c) { - // Play at Intercept - case EVENT_LANCASTER_FLANK_ATTACK: - case EVENT_YORK_FLANK_ATTACK: - set_add(game.events, c) - break - } -} - states.intercept = { inactive: "Intercept", prompt() { view.prompt = `Choose lord to intercept moving lords?` - let to = get_lord_locale(game.command) - prompt_held_event_intercept() + if (game.active === YORK) + gen_action_card_if_held(EVENT_YORK_FLANK_ATTACK) + else + gen_action_card_if_held(EVENT_LANCASTER_FLANK_ATTACK) if (game.who === NOBODY) { + let to = get_lord_locale(game.command) for (let next of data.locales[to].not_paths) for_each_friendly_lord_in_locale(next, gen_action_lord) } else { @@ -4759,7 +4733,11 @@ states.intercept = { set_toggle(game.intercept_group, lord) } }, - card: action_held_event_at_intercept, + card(c) { + push_undo() + play_held_event(c) + set_add(game.events, c) + }, pass() { set_active_enemy() end_intercept() @@ -4767,9 +4745,8 @@ states.intercept = { intercept() { let valour = data.lords[game.who].valour let success = false - if (is_event_in_play(EVENT_LANCASTER_FLANK_ATTACK) || is_event_in_play(EVENT_YORK_FLANK_ATTACK)) { + if (is_flank_attack_in_play()) { success = true - // FIXME: swap_battle_attacker = 1 ??? } else { let roll = roll_die() @@ -4845,8 +4822,8 @@ function for_each_friendly_lord_in_locale(loc: Locale, f) { // === MARCH EVENT: FLANK ATTACK === -function can_play_flank_attack() { - return game.state === "intercept" && game.who !== NOBODY && !is_truce_in_effect() +function is_flank_attack_in_play() { + return is_event_in_play(EVENT_LANCASTER_FLANK_ATTACK) || is_event_in_play(EVENT_YORK_FLANK_ATTACK) } // === MARCH EVENT: KING'S PARLEY === @@ -5349,6 +5326,13 @@ function goto_battle() { defender_artillery: 0, } + if (is_flank_attack_in_play()) { + if (game.battle.attacker === YORK) + game.battle.attacker = LANCASTER + else + game.battle.attacker = YORK + } + // Troops by capability add_battle_capability_troops() @@ -8307,7 +8291,6 @@ exports.setup = function (seed, scenario, options) { succession: 0, supply_depot: 0, surprise_landing: 0, - swap_battle_attacker: 0, warden_of_the_marches: 0, }, |