Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-07-29 10:29:54 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-07-29 10:29:54 -0700
commit63fb4139d5ac5207b057bce46c4288df982bbeb1 (patch)
tree80b2b0c839d94e3af04cc9f2df6c45c169f600d2 /src/index.js
parente746cfb216836e26a6c060558278d724bd3ed5d5 (diff)
Add ability to deactivate/reactivate soldier records; make hex clearing work with right-click and add a confirmation modal dialog
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js8
1 files changed, 6 insertions, 2 deletions
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' });
+ }
})
);