Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-05-23 12:06:01 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-05-23 12:06:01 -0700
commitd729079cdf63a4382e3e3225295784124e0a4d5d (patch)
treed3ccd936e9e294a0492f7cb261d3266f133cc1d5 /src/modules/gameboard.js
parentd06277bad51439595a02b449f50ce43645355d45 (diff)
WIP: intercept request in test
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);