Add turn counter and inning indicator

This commit is contained in:
Catalin Mititiuc 2024-04-06 15:09:09 -07:00
parent 5e2a62bb7a
commit 5afa53ef7a
3 changed files with 30 additions and 1 deletions

View File

@ -242,6 +242,12 @@
</button> </button>
<br> <br>
Prone: <input type="checkbox" id="toggle-prone-counter" /> Prone: <input type="checkbox" id="toggle-prone-counter" />
Turn:
<span id="turn-count" data-update="0">
<span name="count">0</span>
<span class="inning-top"></span>
<span class="inning-bottom"></span>
</span>
</div> </div>
<div id="record-sheet"> <div id="record-sheet">

View File

@ -915,7 +915,22 @@ document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click'
document.querySelectorAll('.end-turn').forEach(el => document.querySelectorAll('.end-turn').forEach(el =>
el.addEventListener('click', ({ target: { dataset: { allegiance }}}) => { el.addEventListener('click', ({ target: { dataset: { allegiance }}}) => {
let dataSelector = `[data-troop-allegiance="${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()); qA(`#firing-arcs ${dataSelector}`).forEach(el => el.remove());

View File

@ -400,6 +400,14 @@ img.logo {
display: block; display: block;
} }
#turn-count[data-update="0"] span.inning-bottom {
display: none;
}
#turn-count[data-update="1"] span.inning-top {
display: none;
}
@media (width >= 1800px) { @media (width >= 1800px) {
#record-sheet { #record-sheet {
flex-direction: row; flex-direction: row;