diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-09-24 13:34:13 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-01 16:11:22 +0200 |
commit | 1ea6f67ad23fff74c2cd315107bd68eccd224153 (patch) | |
tree | 8ad96b704bd7a25a218164514fed2812efaacdaa | |
parent | b6d6cd49d0e77338c1a71640476ef17dfb89bfe9 (diff) | |
download | waterloo-campaign-1815-1ea6f67ad23fff74c2cd315107bd68eccd224153.tar.gz |
Fix bugs. Move turn track away from main board.
-rw-r--r-- | play.css | 9 | ||||
-rw-r--r-- | play.html | 4 | ||||
-rw-r--r-- | play.js | 10 | ||||
-rw-r--r-- | rules.js | 54 |
4 files changed, 52 insertions, 25 deletions
@@ -26,18 +26,19 @@ body.Coalition header.your_turn { background-color: white; } main { background-color: dimgray; + background-color: hsl(39, 10%, 40%); } #mapwrap { margin: 0 auto; width: 2550px; - height: 1900px; + height: 1940px; } #map { position: absolute; width: 2550px; - height: 1900px; + height: 1940px; } #board, #tracks, #hexes, #pieces { @@ -56,8 +57,8 @@ main { } #tracks { - top: 1650px; - left: 0px; + top: 1670px; + left: 20px; width: 600px; height: 250px; background-color: #d0c5b1; @@ -63,8 +63,8 @@ <div id="hexes"></div> <div id="pieces"> -<div id="marker_turn" class="marker large y1" style="top:1660px;left:25px"></div> -<div id="marker_remain" class="marker large y3" style="top:1837px;left:109px"></div> +<div id="marker_turn" class="marker large y1" style="top:1665px;left:45px"></div> +<div id="marker_remain" class="marker large y3" style="top:1857px;left:129px"></div> <div id="french_hq_1" class="french large y1"></div> <div id="french_hq_2" class="french large y2"></div> @@ -66,8 +66,8 @@ function map_get(map, key, missing) { const FRENCH = "French" const COALITION = "Coalition" -const TURN_X = 20 - 70 + 35 + 8 -const TURN_Y = 1745 +const TURN_X = 20 - 70 + 35 + 8 + 20 +const TURN_Y = 1745 + 20 const TURN_DX = 70 const REINF_OFFSET = { @@ -358,8 +358,8 @@ function on_update() { // OFF MAP DETACHMENTS / LEADERS / REINFORCEMENTS ui.pieces[id].classList.remove("hide") ui.pieces[id].classList.toggle("flip", (view.pieces[id] & 1) === 1) - let x = 600 + 40 + ui.stack[hex] * 60 - let y = 1650 + 40 + 60 * (hex-AVAILABLE_P1) + let x = 600 + 40 + ui.stack[hex] * 60 + 40 + let y = 1650 + 40 + 60 * (hex-AVAILABLE_P1) + 20 ui.stack[hex] += 1 ui.pieces[id].style.top = y + "px" ui.pieces[id].style.left = x + "px" @@ -406,7 +406,7 @@ function on_update() { ui.turn.style.left = (40 + TURN_X + (view.turn-1) * TURN_DX) + "px" ui.turn.classList.toggle("flip", view.rain > 0) - ui.remain.style.left = (109 + (view.remain % 10) * 47.5 | 0) + "px" + ui.remain.style.left = (20 + 109 + (view.remain % 10) * 47.5 | 0) + "px" ui.remain.classList.toggle("flip", view.remain > 9) action_button("blow", "Blow") @@ -5,9 +5,14 @@ // TODO: inactive prompts // TODO: prompts - Done when no more to do -// TODO: recall grand battery if alone // TODO: rain effect on movement -// TODO: enemy or enemy zoc on entry or adjacent hex special case retreat/recall +// TODO: forbidden - enemy or enemy zoc on entry or adjacent hex special case retreat/recall + +// TODO: june 15 special rules + +// TODO: pause after last battle before next turn +// TODO: confirm attack step? +// TODO: roll attack step? const P1 = "French" const P2 = "Coalition" @@ -179,6 +184,7 @@ const p1_corps = make_piece_list(p => p.side === P1 && (p.type === "inf" || p.ty const p2_corps = make_piece_list(p => p.side !== P1 && (p.type === "inf" || p.type === "cav")) 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")) function friendly_hqs() { return (game.active === P1) ? p1_hqs : p2_hqs } function enemy_hqs() { return (game.active !== P1) ? p1_hqs : p2_hqs } @@ -360,7 +366,7 @@ function recall_grand_battery_alone() { } function recall_detachment(p) { - log("P" + p + "\nfrom " + piece_hex(p)) + log("P" + p + " recalled from " + piece_hex(p) + ".") if (set_has(p1_det, p)) set_piece_hex(p, AVAILABLE_P1) else @@ -490,6 +496,7 @@ states.place_hq = { } }, end_step() { + clear_undo() end_hq_placement_step() }, } @@ -582,7 +589,6 @@ states.eliminate_blown = { gen_action_piece(p) }, piece(p) { - push_undo() eliminate_unit(p) resume_return_blown_1() }, @@ -612,8 +618,7 @@ states.return_blown_who = { piece(p) { push_undo() update_zoc() - if (game.count > 0 && can_return_blown_unit(p)) { - --game.count + if (can_return_blown_unit(p)) { game.who = p game.state = "return_blown_where" } else { @@ -621,6 +626,7 @@ states.return_blown_who = { } }, end_step() { + clear_undo() end_return_blown() }, } @@ -646,7 +652,7 @@ states.return_blown_where = { log("P" + game.who + "\nto " + x) set_piece_hex(game.who, x) game.who = -1 - game.state = "return_blown" + game.state = "return_blown_who" }, } @@ -719,6 +725,7 @@ states.place_detachment_hq = { game.state = "place_detachment_who" }, end_step() { + clear_undo() end_detachment_placement_step() }, } @@ -839,6 +846,7 @@ states.detachment_recall_step = { recall_detachment(p) }, end_step() { + clear_undo() end_detachment_recall_step() }, } @@ -918,6 +926,7 @@ function goto_withdrawal() { } function next_withdrawal() { + clear_undo() game.state = "withdrawal" if (game.remain === 0) { @@ -939,9 +948,12 @@ function pass_withdrawal() { end_withdrawal() } else { set_next_player() - game.remain = 3 - if (!can_withdraw_any()) - pass_withdrawal() + if (can_withdraw_any()) { + game.remain = 3 + } else { + log(game.active + " passed.") + end_withdrawal() + } } } @@ -1016,7 +1028,7 @@ function bring_on_reinforcements() { for (let p of info.list) if (piece_hex(p) !== SWAPPED) set_piece_hex(p, REINFORCEMENTS) - for (let p of friendly_units()) + for (let p of all_units) if (piece_hex(p) === BLOWN + game.turn) set_piece_hex(p, BLOWN) } @@ -1045,6 +1057,7 @@ function goto_movement_phase() { } function next_movement() { + clear_undo() game.state = "movement" game.who = -1 @@ -1085,7 +1098,8 @@ function pass_movement() { game.remain += n } else { - pass_movement() + log(game.active + " passed.") + end_movement() } } } @@ -1172,7 +1186,6 @@ states.movement_to = { set_piece_hex(game.who, x) log("P" + game.who + "\nfrom " + from + "\nto " + x) - log("") // must flip (stream without road, or enter zoc) if (move_flip[x-1000]) @@ -1185,6 +1198,8 @@ states.movement_to = { game.who = -1 recall_grand_battery_alone() + + log("") next_movement() }, } @@ -1393,6 +1408,8 @@ function search_move_normal(start, ma, hq_hex, hq_range, is_cav) { let here = queue.shift() let mp = move_cost[here-1000] + // console.log("HERE", here, mp) + for_each_adjacent(here, next => { if (!can_move_into(here, next, hq_hex, hq_range, is_cav)) return @@ -1405,6 +1422,8 @@ function search_move_normal(start, ma, hq_hex, hq_range, is_cav) { else if (must_stop_zoc_zoi(here, next, is_cav)) next_mp = 0 + // console.log(" INTO", next, mp) + let seen_mp = move_cost[next-1000] if (seen_mp === 255 || next_mp > seen_mp) { map_set(move_from, next, here) @@ -1574,7 +1593,8 @@ function pass_attack() { game.remain = roll_die() log("Rolled D" + game.remain + ".") } else { - pass_attack() + log(game.active + " passed.") + end_attack() } } } @@ -1650,10 +1670,14 @@ states.attack_who = { game.target = p game.attack = piece_hex(game.target) begin_attack() + + // TODO: confirm attack step? + // TODO: roll attack step? }, } function begin_attack() { + clear_undo() game.count = 0 for (let p of friendly_infantry_corps()) if (can_attack_infantry_support(p)) @@ -1700,6 +1724,7 @@ states.attack_support = { game.count |= (1 << p) }, next() { + clear_undo() goto_defend_support() }, } @@ -1718,6 +1743,7 @@ states.defend_support = { game.count |= (1 << p) }, next() { + clear_undo() goto_resolve_attack() }, } |