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-27 12:24:51 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-27 12:24:51 -0700 |
commit | 25c74d9a8eafe35abd92fa3bdb6b3146614e7fa1 (patch) | |
tree | a5ce4597437c4779b97fb19554624ebd189b5915 /src/modules/game.js | |
parent | 77f9f8afa41b56d4b3be3e3390ff7c24ff224d9e (diff) |
Remove 'reveal pattern' from sight line module
Diffstat (limited to 'src/modules/game.js')
-rw-r--r-- | src/modules/game.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/modules/game.js b/src/modules/game.js index 1faad8d..d60eff0 100644 --- a/src/modules/game.js +++ b/src/modules/game.js @@ -1,5 +1,5 @@ import * as firingArc from './game/firingArc.js'; -import SightLine from './game/sightLine.js'; +import * as sightLine from './game/sightLine.js'; import Counter from './game/counter.js'; const svgns = "http://www.w3.org/2000/svg"; @@ -77,21 +77,21 @@ function getSelected() { } function clearSightLine() { - sightLine.hexes = []; + sightLine.setHexes([]); sightLine.clear(); distanceCallback && distanceCallback(); } function updateSightLine(cell) { const { dataset: { x: sX }, parentElement: { dataset: { y: sY }}} = cell, - { dataset: { x: tX }, parentElement: { dataset: { y: tY }}} = sightLine.lockTarget; + { dataset: { x: tX }, parentElement: { dataset: { y: tY }}} = sightLine.getLockTarget(); const selector = sightLine.calcIndexes(+sX, +sY, +tX, +tY) .map(([x, y]) => `g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`) .join(', '); const hexes = svg.querySelectorAll(selector); - sightLine.hexes = hexes; + sightLine.setHexes(hexes); sightLine.update(getCellPosition(cell)); distanceCallback && distanceCallback(hexes.length - 1); } @@ -105,14 +105,15 @@ function drawSightLine(sourceCell, targetCell) { .join(', '); const hexes = svg.querySelectorAll(selector); - sightLine.hexes = hexes; - sightLine.drawLine(getCellPosition(sourceCell), getCellPosition(targetCell)); + sightLine.setHexes(hexes); + const line = sightLine.create(getCellPosition(sourceCell), getCellPosition(targetCell)); + svg.querySelector('.board').appendChild(line); distanceCallback && distanceCallback(hexes.length - 1); } let svg, distanceCallback, proneFlagCallback, selectCallback; -let board, sightLine, counterMod, +let board, counterMod, placing = []; export function setDistanceCallback(callback) { @@ -130,7 +131,6 @@ export function setSelectCallback(callback) { export function start(el) { svg = el; board = svg.querySelector('.board'); - sightLine = SightLine(board); counterMod = Counter(svg, board); getCells(svg).forEach(cell => { |