Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/index.js b/src/index.js
index b4216be..d6204e8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,7 +18,7 @@ const RecordSheet = new function () {
this.select = function (data) {
this.unSelect();
- document.querySelector(`#record-sheet .soldier-record[data-troop-number="${data.number}"][data-troop-allegiance="${data.allegiance}"]`).classList.add('selected');
+ document.querySelector(`#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]`).classList.add('selected');
document.getElementById('toggle-prone-counter').checked = data.prone;
};
@@ -121,8 +121,7 @@ window.addEventListener('load', () => {
game.unSelect();
RecordSheet.unSelect();
} else {
- const { troopAllegiance: allegiance, troopNumber: number } = el.dataset;
- game.select({ dataset: { allegiance, number }});
+ game.select(el);
}
})
);
@@ -134,7 +133,7 @@ window.addEventListener('load', () => {
document.querySelectorAll('.end-turn').forEach(el =>
el.addEventListener('click', ({ target: { dataset: { allegiance }}}) => {
- let dataSelector = `[data-troop-allegiance="${allegiance}"]`,
+ let dataSelector = `[data-allegiance="${allegiance}"]`,
records = Array.from(document.querySelectorAll(`.soldier-record${dataSelector}`)),
turnCounter = document.getElementById('turn-count'),
{ textContent: count, dataset: { update }} = turnCounter;
@@ -153,12 +152,11 @@ window.addEventListener('load', () => {
}
records
- .sort((el1, el2) => el1.dataset.troopNumber > el2.dataset.troopNumber)
+ .sort((el1, el2) => el1.dataset.number > el2.dataset.number)
.forEach(el => el.classList.remove('movement-ended'));
game.endTurn(allegiance);
- const { troopAllegiance, troopNumber } = records.at(0).dataset;
- game.select({ dataset: { allegiance: troopAllegiance, number: troopNumber }});
+ game.select(records.at(0));
})
);