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-05-22 09:20:54 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-22 09:20:54 -0700 |
commit | 556abf9bbf2e524f1fbe3c44d6fed24192ff4cce (patch) | |
tree | 016421554debc51d0ffbb6e7d92b3cc625c519aa /src/modules/gameboard.js | |
parent | 98e4fd58d8c222652f3a5bd1d8a76f7618824e17 (diff) |
Use observable for showing hex distance count
Diffstat (limited to 'src/modules/gameboard.js')
-rw-r--r-- | src/modules/gameboard.js | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js index 48a32bb..4b7d87b 100644 --- a/src/modules/gameboard.js +++ b/src/modules/gameboard.js @@ -3,7 +3,7 @@ import * as sightLine from './game/sight_line.js'; import * as soldier from './game/soldier.js'; import { Observable } from "./observable"; -let svg, distanceCallback, selected, +let svg, selected, placing = []; function getCellContents(cell) { @@ -89,7 +89,7 @@ function deselect() { function clearSightLine() { sightLine.setHexes([]); sightLine.clear(); - distanceCallback && distanceCallback(); + Observable.notify('distance'); } function updateSightLine(cell) { @@ -103,7 +103,7 @@ function updateSightLine(cell) { const hexes = svg.querySelectorAll(selector); sightLine.setHexes(hexes); sightLine.update(getCellPosition(cell)); - distanceCallback && distanceCallback(hexes.length - 1); + Observable.notify('distance', hexes.length - 1); } function drawSightLine(sourceCell, targetCell) { @@ -118,7 +118,7 @@ function drawSightLine(sourceCell, targetCell) { sightLine.setHexes(hexes); const line = sightLine.create(getCellPosition(sourceCell), getCellPosition(targetCell)); svg.querySelector('.gameboard').appendChild(line); - distanceCallback && distanceCallback(hexes.length - 1); + Observable.notify('distance', hexes.length - 1); } function moveBackOneStepInHistory(counter) { @@ -178,10 +178,6 @@ export function getUnits() { return soldier.getAllCounters(svg); } -export function setDistanceCallback(callback) { - distanceCallback = callback; -} - export function start(el) { svg = el; |