diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-06-05 23:12:59 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-06-05 23:12:59 +0200 |
commit | 203e5ccbf475135e5e177cda78f0acb00aa5f7fb (patch) | |
tree | 46f9ec1efd8e73f9b08f5c593f47f7372da02730 | |
parent | bf604c0ad20aa4e158e744a15a321efe7cc78552 (diff) | |
download | friedrich-203e5ccbf475135e5e177cda78f0acb00aa5f7fb.tar.gz |
fixup move paths
-rw-r--r-- | play.css | 14 | ||||
-rw-r--r-- | play.html | 2 | ||||
-rw-r--r-- | play.js | 8 | ||||
-rw-r--r-- | rules.js | 31 |
4 files changed, 30 insertions, 25 deletions
@@ -438,21 +438,11 @@ span.suit.reserve { font-weight: bold; font-family: "Source Serif SmText"; } /* ROADS */ .space.move { - background-color: #fff8; -} - -.space.move_end { - background-color: #0f08; + background-color: #fff6; } svg .road { - stroke: white; - stroke-width: 6; - stroke-linecap: round; -} - -svg .main_road { - stroke: white; + stroke: red; stroke-width: 6; stroke-linecap: round; } @@ -41,7 +41,7 @@ <div id="mapwrap"> <div id="map"> - <svg id="roads" width="2485" height="1654"></svg> + <svg id="roads" width="2485" height="1654" style="position:absolute;z-index:1;pointer-events:none;"></svg> <div id="spaces"></div> <div id="markers"></div> <div id="pieces"></div> @@ -383,14 +383,16 @@ function make_road(a, b, type) { let x2 = data.cities.x[b] let y2 = data.cities.y[b] + /* let v = Math.hypot(x2 - x1, y2 - y1) let dx = (x2 - x1) / v let dy = (y2 - y1) / v - let r = 0 + let r = 18 x1 += r * dx y1 += r * dy x2 -= r * dx y2 -= r * dy + */ e.setAttribute("x1", x1) e.setAttribute("y1", y1) @@ -841,7 +843,7 @@ function on_init() { for (let a = 0; a <= last_city; ++a) { for (let b of data.cities.main_roads[a]) if (a < b) - make_road(a, b, "main_road") + make_road(a, b, "road") for (let b of data.cities.roads[a]) if (a < b) make_road(a, b, "road") @@ -1027,6 +1029,7 @@ function layout_train(id, s) { e.style.left = (x - 14 + n * 33) + "px" e.style.top = (y - 21 - n * 0) + "px" + e.style.zIndex = y e.classList.toggle("selected", set_has(view.selected, id)) } @@ -1044,6 +1047,7 @@ function create_conquest(style, s) { e.dataset.id = s e.style.left = (x - 16) + "px" e.style.top = (y - 16) + "px" + e.style.zIndex = 1 e.className = style return e } @@ -858,10 +858,8 @@ function retire_general(p) { n -= x } } - if (n > 1) + if (n > 0) log("P" + p + " removed from S" + s + " with " + n + " troops.") - else if (n === 1) - log("P" + p + " removed from S" + s + " with 1 troop.") else log("P" + p + " removed.") } else { @@ -869,8 +867,11 @@ function retire_general(p) { } } -function eliminate_general(p) { - log(">P" + p + " eliminated") +function eliminate_general(p, indent) { + if (indent) + log(">P" + p + " eliminated") + else + log("P" + p + " eliminated.") game.pos[p] = ELIMINATED game.troops[p] = 0 set_in_supply(p) @@ -1585,7 +1586,10 @@ function move_general_to(to) { // eliminate supply train for (let p of all_enemy_trains[pow]) { if (game.pos[p] === to) { - eliminate_train(p) + if (!game.move_elim) + game.move_elim = [] + set_add(game.move_elim, p) + game.pos[p] = ELIMINATED stop = true } } @@ -1828,6 +1832,12 @@ states.move_give = { function end_move_piece() { log_selected_move_path() + if (game.move_elim) { + for (let p of game.move_elim) + log("P" + p + " eliminated.") + delete game.move_elim + } + delete game.move_path game.selected = null game.state = "movement" @@ -2683,7 +2693,7 @@ states.retreat_eliminate_hits = { gen_action_piece(p) }, piece(p) { - eliminate_general(p) + eliminate_general(p, false) set_delete(game.selected, p) resume_retreat() }, @@ -2697,9 +2707,9 @@ states.retreat_eliminate_trapped = { gen_action_piece(p) }, piece(_) { - log("Trapped") + log("Trapped.") for (let p of game.selected) - eliminate_general(p) + eliminate_general(p, false) next_combat() }, } @@ -3029,7 +3039,8 @@ states.supply_eliminate = { for (let p of all_power_generals[game.power]) if (game.pos[p] === s) - eliminate_general(p) + eliminate_general(p, true) + resume_supply_eliminate() }, } |