Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <Catalin.Mititiuc@gmail.com>2024-04-06 15:09:09 -0700
committerCatalin Mititiuc <Catalin.Mititiuc@gmail.com>2024-04-06 15:09:09 -0700
commit5afa53ef7aa1ecf50d2ba2eaebb4df0b4337a8a9 (patch)
tree8fa88165cbfb580f4070020dc929dd12c46e6439 /index.js
parent5e2a62bb7aa58889e19665fd7c55ff1185ccfbe0 (diff)
Add turn counter and inning indicator
Diffstat (limited to 'index.js')
-rw-r--r--index.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/index.js b/index.js
index e52bf71..ee2d3ad 100644
--- a/index.js
+++ b/index.js
@@ -915,7 +915,22 @@ document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click'
document.querySelectorAll('.end-turn').forEach(el =>
el.addEventListener('click', ({ target: { dataset: { allegiance }}}) => {
let dataSelector = `[data-troop-allegiance="${allegiance}"]`,
- records = Array.from(qA(`.soldier-record${dataSelector}`));
+ records = Array.from(qA(`.soldier-record${dataSelector}`)),
+ turnCounter = document.getElementById('turn-count'),
+ { textContent: count, dataset: { update }} = turnCounter;
+
+ el.setAttribute('disabled', '');
+
+ document
+ .querySelector(`button.end-turn:not([data-allegiance="${allegiance}"])`)
+ .removeAttribute('disabled');
+
+ if (update == '1') {
+ turnCounter.children.namedItem('count').textContent++
+ turnCounter.dataset.update = '0';
+ } else {
+ turnCounter.dataset.update = '1';
+ }
qA(`#firing-arcs ${dataSelector}`).forEach(el => el.remove());