From 163e3a9de59f5d6a8df38fa32a1e7dc4db1ad024 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Sat, 1 Jun 2024 17:50:58 -0700
Subject: Fix/refactor tests
---
src/modules/gameboard.js | 8 ++++++++
src/modules/record_sheet.js | 5 +++++
2 files changed, 13 insertions(+)
(limited to 'src/modules')
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 38a9a9a..97538cd 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -175,6 +175,7 @@ function selectOffBoard() {
}
function select(data) {
+ console.log('select', data);
const counter = data && (soldier.getCounter(svg, data) || soldier.createCounter(data));
const isSelected = counter?.classList.contains(soldier.getSelectedClass());
@@ -204,6 +205,8 @@ export function start(el) {
startingLocations && getUnits(startingLocations).forEach(unit => unit.addEventListener('click', selectOffBoard));
getCells(svg).forEach(cell => {
+ if (cell.dataset.x === '0' && cell.parentElement.dataset.y === '0') console.log('cell', cell);
+
cell.addEventListener('click', e => {
const occupant = getCellOccupant(cell);
let toPlace = placing.pop();
@@ -300,6 +303,11 @@ export function start(el) {
console.log('gameboard.js loaded');
}
+export function stop() {
+ Observable.unsubscribe('select', select);
+ Observable.unsubscribe('endmove', endMove);
+}
+
export function getUnits() {
return soldier.getAllCounters(svg);
}
diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js
index 33a21fe..53f6d83 100644
--- a/src/modules/record_sheet.js
+++ b/src/modules/record_sheet.js
@@ -195,3 +195,8 @@ export function start(startLoc, units) {
Observable.subscribe('select', select);
Observable.subscribe('endmove', endMove);
}
+
+export function stop() {
+ Observable.unsubscribe('select', select);
+ Observable.unsubscribe('endmove', endMove);
+}
--
cgit v1.2.3