Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/gameboard.js')
-rw-r--r--src/modules/gameboard.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 8f03603..48a32bb 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -3,8 +3,7 @@ import * as sightLine from './game/sight_line.js';
import * as soldier from './game/soldier.js';
import { Observable } from "./observable";
-let svg, distanceCallback, proneFlagCallback,
- selected,
+let svg, distanceCallback, selected,
placing = [];
function getCellContents(cell) {
@@ -78,6 +77,7 @@ function getSelected() {
function deselect() {
const selected = getSelected();
placing = [];
+ Observable.notify('proneflag', false);
if (selected) {
selected.classList.remove(soldier.getSelectedClass());
@@ -182,10 +182,6 @@ export function setDistanceCallback(callback) {
distanceCallback = callback;
}
-export function setProneFlagCallback(callback) {
- proneFlagCallback = callback;
-}
-
export function start(el) {
svg = el;
@@ -231,6 +227,9 @@ export function start(el) {
console.log('removing cell contents');
getCellContents(cell).forEach(el => el.remove());
}
+
+ const selected = getSelected();
+ Observable.notify('proneflag', selected && soldier.hasProne(selected));
});
cell.addEventListener('dblclick', e => {
@@ -280,6 +279,7 @@ export function start(el) {
});
Observable.subscribe('select', select);
+ Observable.subscribe('endmove', endMove);
console.log('gameboard.js loaded');
}
@@ -295,6 +295,7 @@ export function select(data) {
counter.classList.add(soldier.getSelectedClass());
firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
+ Observable.notify('proneflag', soldier.hasProne(counter));
placing.push(counter);
}