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-08-02 14:37:20 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-08-02 14:37:20 -0700 |
commit | a042537c8eeff2e45bcc5d678e2657f4f542ec93 (patch) | |
tree | 6d7a5bc0ad04eb6cce6a1948cd8e8e671399bc87 /src/modules/game/firing_arc.js | |
parent | f6ee6e3560022c77724535c2f7abd98c474ced8c (diff) |
Fix firing arcs for squads
Diffstat (limited to 'src/modules/game/firing_arc.js')
-rw-r--r-- | src/modules/game/firing_arc.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/modules/game/firing_arc.js b/src/modules/game/firing_arc.js index 7a82c43..5a9e5b2 100644 --- a/src/modules/game/firing_arc.js +++ b/src/modules/game/firing_arc.js @@ -190,13 +190,14 @@ function calcPoints(e, aimLine, grid, size) { return { aimPt, outlinePoints, arcPoints }; } -function setDataAttrs({ dataset: { allegiance, number }}, el) { +function setDataAttrs({ dataset: { allegiance, number, squad }}, el) { el.dataset.allegiance = allegiance; el.dataset.number = number; + el.dataset.squad = squad; } -function getClipPathId({ dataset: { allegiance, number }}) { - return `clip-path-${allegiance}-${number}`; +function getClipPathId({ dataset: { allegiance, number, squad }}) { + return `clip-path-${allegiance}-${squad}-${number}`; } function getUnclipped(svg) { @@ -310,8 +311,11 @@ function clear(svg, allegiance) { svg.querySelectorAll(selector).forEach(el => el.remove()); } -function get(svg, { dataset: { allegiance, number }}) { - return svg.querySelectorAll(`#firing-arcs [data-number="${number}"][data-allegiance="${allegiance}"], #firing-arcs line`); +function get(svg, { dataset: { allegiance, number, squad }}) { + return svg.querySelectorAll( + `#firing-arcs [data-number="${number}"][data-allegiance="${allegiance}"][data-squad="${squad}"], + #firing-arcs line` + ); } function toggleVisibility(svg, allegiance) { @@ -322,20 +326,19 @@ function toggleVisibility(svg, allegiance) { firingArcVisibility[allegiance] = !vis; } -function toggleCounterVisibility(svg, { dataset: { number, allegiance }}, vis) { - const cp = svg.querySelector(`#clip-path-${allegiance}-${number}`), +function toggleCounterVisibility(svg, counter, vis) { + const cp = svg.querySelector(`#${getClipPathId(counter)}`), display = vis ? 'none' : ''; if (cp) { - cp.style.display = firingArcVisibility[allegiance] ? 'none' : display; + cp.style.display = firingArcVisibility[counter.dataset.allegiance] ? 'none' : display; } } function clipAll(svg) { getUnclipped(svg).forEach(el => { - const { number, allegiance } = el.dataset, - clipPathId = `clip-path-${allegiance}-${number}`, - isVisible = firingArcVisibility[allegiance]; + const clipPathId = getClipPathId(el), + isVisible = firingArcVisibility[el.dataset.allegiance]; if (isVisible) { svg.querySelector(`#${clipPathId}`).style.display = 'none'; |