index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-30 14:58:19 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-30 14:58:19 -0700 |
commit | 6811f68b3688cdbb5845f15bd3da42fa6ccc580b (patch) | |
tree | 2a150518af7600885db692dfc37c2e21bf0d780e /src | |
parent | bbd29206cdeba1ffc773dbb12c88da7b5d7a8ad8 (diff) |
Fix end movement bug
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/game/soldier.js | 25 | ||||
-rw-r--r-- | src/modules/gameboard.js | 4 |
2 files changed, 7 insertions, 22 deletions
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js index c4e9753..db5fd3d 100644 --- a/src/modules/game/soldier.js +++ b/src/modules/game/soldier.js @@ -25,10 +25,6 @@ function getClones(svg, counter) { return svg.querySelectorAll(`.counter.clone${dataSelector(counter)}`); } -function getCounterAndClones(svg, counter) { - return svg.querySelectorAll(`.counter${dataSelector(counter)}`); -} - export function getAllCounters(container) { return container.querySelectorAll('g.counter[data-allegiance][data-number]'); } @@ -42,10 +38,7 @@ export function getTrace(svg, counter) { } export function place(svg, selected, cell) { - let points, - counterNodeList = getCounterAndClones(svg, selected); - - if (counterNodeList.length > 0 && svg.querySelector('.grid').contains(selected)) { + if (svg.querySelector('.grid').contains(selected)) { let trace = svg.querySelector(traceSelector(selected)); let prevCoords = [ @@ -70,7 +63,8 @@ export function place(svg, selected, cell) { }); let previous = getCellPosition(clone.parentElement), - current = getCellPosition(selected.parentElement); + current = getCellPosition(selected.parentElement), + points; if (!trace) { trace = document.createElementNS(svgns, 'polyline'); @@ -98,20 +92,15 @@ export function removeClones(svg, counter) { } export function endMove(svg, counter) { - const trace = svg.querySelector(traceSelector(counter)), - proneCounter = counter.querySelector('[href="#counter-prone"]'); - - if (trace) { - trace.remove(); - } - - delete counter.dataset.previous; + const proneCounter = counter.querySelector('[href="#counter-prone"]'); if (proneCounter) { proneCounter.dataset.preexisting = ''; } - removeClones(counter); + svg.querySelector(traceSelector(counter))?.remove(); + delete counter.dataset.previous; + removeClones(svg, counter); } export function hasProne(counter) { diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js index 678f828..3c932d9 100644 --- a/src/modules/gameboard.js +++ b/src/modules/gameboard.js @@ -30,10 +30,6 @@ function getLockedSightLine(svg) { return svg.querySelector('line.sight-line:not(.active)'); } -function getSightLine() { - return sightLine.getSightLine(); -} - function getActiveSightLine(svg) { return svg.querySelector('line.sight-line.active'); } |