Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/gameboard.js')
-rw-r--r--src/modules/gameboard.js58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 4b7d87b..8b64617 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -174,8 +174,29 @@ function selectOffBoard() {
Observable.notify('select', this);
}
-export function getUnits() {
- return soldier.getAllCounters(svg);
+function select(data) {
+ if (!data) return;
+
+ const counter = soldier.getCounter(svg, data) || soldier.createCounter(data);
+ const isSelected = counter.classList.contains(soldier.getSelectedClass());
+
+ deselect();
+
+ if (isSelected) return;
+
+ counter.classList.add(soldier.getSelectedClass());
+ firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
+ Observable.notify('proneflag', soldier.hasProne(counter));
+ placing.push(counter);
+}
+
+function endMove() {
+ const selected = getSelected();
+
+ if (selected) {
+ soldier.endMove(svg, selected);
+ deselect();
+ }
}
export function start(el) {
@@ -279,29 +300,8 @@ export function start(el) {
console.log('gameboard.js loaded');
}
-export function select(data) {
- if (!data) return;
-
- const counter = soldier.getCounter(svg, data) || soldier.createCounter(data);
- const isSelected = counter.classList.contains(soldier.getSelectedClass());
-
- deselect();
-
- if (isSelected) return;
-
- counter.classList.add(soldier.getSelectedClass());
- firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
- Observable.notify('proneflag', soldier.hasProne(counter));
- placing.push(counter);
-}
-
-export function endMove() {
- const selected = getSelected();
-
- if (selected) {
- soldier.endMove(svg, selected);
- deselect();
- }
+export function getUnits() {
+ return soldier.getAllCounters(svg);
}
export function clearFiringArcs(allegiance) {
@@ -309,12 +309,8 @@ export function clearFiringArcs(allegiance) {
}
export function toggleProne() {
- const selected = getSelected(),
- isOnBoard = selected && selected.parentElement.hasAttribute('data-x');
-
- if (selected && isOnBoard) {
- soldier.toggleProne(selected);
- }
+ const selected = getSelected();
+ if (selected) soldier.toggleProne(selected);
}
export function toggleFiringArcVisibility() {