Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/game.js')
-rw-r--r--src/modules/game.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/modules/game.js b/src/modules/game.js
index 6b59659..1faad8d 100644
--- a/src/modules/game.js
+++ b/src/modules/game.js
@@ -1,4 +1,4 @@
-import FiringArc from './game/firingArc.js';
+import * as firingArc from './game/firingArc.js';
import SightLine from './game/sightLine.js';
import Counter from './game/counter.js';
@@ -112,7 +112,7 @@ function drawSightLine(sourceCell, targetCell) {
let svg, distanceCallback, proneFlagCallback, selectCallback;
-let board, firingArc, sightLine, counterMod,
+let board, sightLine, counterMod,
placing = [];
export function setDistanceCallback(callback) {
@@ -130,7 +130,6 @@ export function setSelectCallback(callback) {
export function start(el) {
svg = el;
board = svg.querySelector('.board');
- firingArc = FiringArc(svg, board);
sightLine = SightLine(board);
counterMod = Counter(svg, board);
@@ -264,7 +263,7 @@ export function start(el) {
let occupant = getCellOccupant(cell);
if (occupant) {
- firingArc.toggleCounterVisibility(occupant, true);
+ firingArc.toggleCounterVisibility(svg, occupant, true);
}
});
@@ -278,7 +277,7 @@ export function start(el) {
let occupant = getCellOccupant(cell);
if (occupant) {
- firingArc.toggleCounterVisibility(occupant, false);
+ firingArc.toggleCounterVisibility(svg, occupant, false);
}
});
});
@@ -296,7 +295,7 @@ export function select(selected) {
unSelect();
placing.push(counter);
counter.classList.add(counterMod.selectedClass);
- firingArc.get(counter).forEach(el => el.removeAttribute('clip-path'));
+ firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
selectCallback && selectCallback({ prone: counterMod.hasProne(counter), ...counter.dataset });
}
}
@@ -308,7 +307,7 @@ export function unSelect() {
placing = [];
getSelected().classList.remove(counterMod.selectedClass);
clearSightLine();
- firingArc.clipAll();
+ firingArc.clipAll(svg);
}
}
@@ -322,7 +321,7 @@ export function endMove() {
}
export function endTurn(allegiance) {
- firingArc.clear(allegiance);
+ firingArc.clear(svg, allegiance);
}
export function toggleProne() {
@@ -335,7 +334,7 @@ export function toggleProne() {
}
export function toggleFiringArcVisibility(allegiance) {
- firingArc.toggleVisibility(allegiance);
+ firingArc.toggleVisibility(svg, allegiance);
}
export function setFiringArc(size) {
@@ -343,7 +342,7 @@ export function setFiringArc(size) {
isOnBoard = counter => counter && counter.parentElement.hasAttribute('data-x');
if (isOnBoard(counter)) {
- firingArc.set(size, counter, getCellPosition(counter.parentElement));
+ firingArc.set(svg, size, counter, getCellPosition(counter.parentElement));
}
}