Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/gameboard.js')
-rw-r--r--src/modules/gameboard.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 8b64617..a354795 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -175,14 +175,12 @@ function selectOffBoard() {
}
function select(data) {
- if (!data) return;
-
- const counter = soldier.getCounter(svg, data) || soldier.createCounter(data);
- const isSelected = counter.classList.contains(soldier.getSelectedClass());
+ const counter = data && (soldier.getCounter(svg, data) || soldier.createCounter(data));
+ const isSelected = counter?.classList.contains(soldier.getSelectedClass());
deselect();
- if (isSelected) return;
+ if (isSelected || !data) return;
counter.classList.add(soldier.getSelectedClass());
firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
@@ -223,7 +221,8 @@ export function start(el) {
placing.push(toPlace);
getLockedSightLine(svg) ? updateSightLine(toPlace.parentElement) : drawSightLine(toPlace.parentElement, cell);
} else {
- deselect();
+ // deselect();
+ Observable.notify('select');
}
} else if (!occupant.classList.contains('clone')) {
Observable.notify('select', occupant);