diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-01-23 19:13:10 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 4544b723416c21a1d1745ed0298f89d4c1d1e2c5 (patch) | |
tree | 8f3cdd526bebc0ae44d5625f466cc2afb193c106 | |
parent | 6cc077a280ac563747838a0ec7252f978a6bb802 (diff) | |
download | wilderness-war-4544b723416c21a1d1745ed0298f89d4c1d1e2c5.tar.gz |
Lake Schooner.
-rw-r--r-- | rules.js | 58 |
1 files changed, 53 insertions, 5 deletions
@@ -38,7 +38,7 @@ [x] george_croghan in enemy movement: [ ] foul weather - [ ] lake schooner + [x] lake schooner [ ] massacre */ @@ -682,6 +682,14 @@ function space_name(s) { return spaces[s].name; } +function is_lake_connection(from, to) { + let exits = spaces[from].lakeshore; + for (let i = 0; i < exits.length; ++i) + if (exits[i] === to) + return true; + return false; +} + function is_wilderness_or_mountain(space) { let type = spaces[space].type; return type === 'wilderness' || type === 'mountain'; @@ -2653,17 +2661,28 @@ states.move = { let cost = game.move.cost[to]; game.move.start_cost = game.move.cost[to]; - // remember where we came from so we can retreat after battle - game.raid.from[to] = game.move.path[to]; + let from = game.move.path[to]; - // TODO: RESPONSE - Lake Schooner + // remember where we came from so we can retreat after battle + game.raid.from[to] = from; - // TODO: except space moved into, if it is guarded! + // TODO: except space moved into, if it is guarded or lake schooner happens! if (force_has_drilled_troops(who)) remove_enemy_forts_uc_in_path(game.move.path, to); move_piece_to(who, to); lift_sieges_and_amphib(); + + // TODO: RESPONSE - Lake Schooner + if (is_card_available(LAKE_SCHOONER)) { + if (has_enemy_fortifications(to) && is_lake_connection(from, to)) { + clear_undo(); + set_active(enemy()); + game.state = 'lake_schooner'; + return; + } + } + goto_intercept(); }, piece(who) { @@ -2680,6 +2699,35 @@ states.move = { }, } +states.lake_schooner = { + prompt() { + let p = moving_piece(); + let to = piece_space(p); + let from = game.move.path[to]; + view.prompt = `${piece_name(p)} moved from ${space_name(from)} to ${space_name(to)}. You may play "Lake Schooner" if available.`; + view.who = p; + view.where = from; + if (player.hand.includes(LAKE_SCHOONER)) + gen_action('play_event', LAKE_SCHOONER); + gen_action_pass(); + }, + play_event(c) { + play_card(c); + let who = moving_piece(); + let to = piece_space(who); + let from = game.move.path[to]; + move_piece_to(who, from); + log(`${piece_name(who)} stops in ${space_name(from)}.`); + game.move.start_cost = 18; // enemy stops in previously occupied space + set_active(enemy()); + resume_move(); + }, + pass() { + set_active(enemy()); + goto_intercept(); + } +} + states.amphibious_landing = { prompt() { let who = moving_piece(); |