From d729079cdf63a4382e3e3225295784124e0a4d5d Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Thu, 23 May 2024 12:06:01 -0700
Subject: WIP: intercept request in test
---
src/modules/gameboard.js | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
(limited to 'src/modules/gameboard.js')
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);
--
cgit v1.2.3