From 63fb4139d5ac5207b057bce46c4288df982bbeb1 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Mon, 29 Jul 2024 10:29:54 -0700
Subject: Add ability to deactivate/reactivate soldier records; make hex
clearing work with right-click and add a confirmation modal dialog
---
src/index.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'src/index.js')
diff --git a/src/index.js b/src/index.js
index 2cd2db6..2e2e306 100644
--- a/src/index.js
+++ b/src/index.js
@@ -145,7 +145,7 @@ async function load() {
document.querySelectorAll('.end-turn').forEach(el =>
el.addEventListener('click', ({ target: { dataset: { allegiance: opponent }}}) => {
const dataSelector = `[data-allegiance="${opponent}"]`,
- opponentRecords = Array.from(document.querySelectorAll(`.soldier-record${dataSelector}`)),
+ opponentRecords = Array.from(document.querySelectorAll(`.soldier-record${dataSelector}:not(.inactive)`)),
firstOpponentRecord = opponentRecords.sort((el1, el2) => el1.dataset.number > el2.dataset.number).at(0);
el.setAttribute('disabled', '');
@@ -154,7 +154,11 @@ document.querySelectorAll('.end-turn').forEach(el =>
clearMoveEndedIndicators(opponentRecords);
gameboard.clearFiringArcs(opponent);
- Observable.notify('select', firstOpponentRecord);
+
+ if (firstOpponentRecord) {
+ Observable.notify('select', firstOpponentRecord);
+ firstOpponentRecord.scrollIntoView({ behavior: 'smooth' });
+ }
})
);
--
cgit v1.2.3