From 82442689adb66ad3f46a52283bff097eb30ec2a9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 24 Sep 2023 19:22:19 +0200 Subject: Allow entering reinforcements from both 1017 and 1018. --- data.js | 2 +- play.js | 3 +++ rules.js | 32 +++++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/data.js b/data.js index 75425d2..8047d7b 100644 --- a/data.js +++ b/data.js @@ -233,7 +233,7 @@ data.reinforcements = [ { turn: 1, side: "French", - hex: 1018, + hex: [1017, 1018], list: [ "III Corps (Vandamme)", "VI Corps (Lobau)", diff --git a/play.js b/play.js index 72d34b3..5736494 100644 --- a/play.js +++ b/play.js @@ -72,6 +72,7 @@ const TURN_DX = 70 const REINF_OFFSET = { 1015: [ hex_dx/2, hex_dy * 3/4 ], + 1017: [ hex_dx/2, hex_dy * 3/4 ], 1018: [ -hex_dx/2, hex_dy * 3/4 ], 1020: [ -hex_dx/2, hex_dy * 3/4 ], 3000: [ -hex_dx/2, 0 ], @@ -333,6 +334,8 @@ function on_update() { let x, y if (hex === REINFORCEMENTS) { hex = find_reinforcement_hex(id) + if (typeof hex !== "number") + hex = hex[0] s = find_reinforcement_z(id) z = 4 - s x = ui.hex_x[hex] + s * 24 diff --git a/rules.js b/rules.js index aed4003..ec186d4 100644 --- a/rules.js +++ b/rules.js @@ -182,6 +182,7 @@ const p2_corps = make_piece_list(p => p.side !== P1 && (p.type === "inf" || p.ty const p1_units = make_piece_list(p => p.side === P1 && (p.type === "inf" || p.type === "cav" || p.type === "det")) const p2_units = make_piece_list(p => p.side !== P1 && (p.type === "inf" || p.type === "cav" || p.type === "det")) const all_units = make_piece_list(p => (p.type === "inf" || p.type === "cav" || p.type === "det")) +const all_corps = make_piece_list(p => (p.type === "inf" || p.type === "cav")) const anglo_det = make_piece_list(p => p.side === "Anglo" && p.type === "det") const prussian_cav = make_piece_list(p => p.side === "Prussian" && p.type === "cav") @@ -1117,11 +1118,11 @@ function goto_movement_phase() { } function next_movement() { - clear_undo() game.state = "movement" game.who = -1 if (game.remain === 0) { + clear_undo() set_next_player() } else { if (--game.remain === 0) { @@ -1171,6 +1172,7 @@ function pass_movement() { } function end_movement() { + clear_undo() if (game.turn <= 2) delete game.french_moves if (game.turn === 2) @@ -1501,13 +1503,33 @@ function search_move(p) { let x = piece_hex(p) let m = piece_movement_allowance(p) let u = 0 + if (x === REINFORCEMENTS) { - x = find_reinforcement_hex(p) - u = 1 - move_seen[x-1000] = 1 - move_flip[x-1000] = 0 + let xs = find_reinforcement_hex(p) + if (typeof xs === "number") { + x = xs + if (!hex_has_any_piece(x, all_corps)) { + u = 1 + move_seen[x-1000] = 1 + move_flip[x-1000] = 0 + search_move_imp(p, m, 1, x) + } + } else { + for (x of xs) { + if (!hex_has_any_piece(x, all_corps)) { + u = 1 + move_seen[x-1000] = 1 + move_flip[x-1000] = 0 + search_move_imp(p, m, 1, x) + } + } + } + } else { + search_move_imp(p, m, 0, x) } +} +function search_move_imp(p, m, u, x) { for (let hq of data.pieces[p].hq) { let hq_hex = piece_hex(hq) if (is_map_hex(hq_hex)) { -- cgit v1.2.3