Web Dev Solutions

Catalin Mititiuc

From 62a745d59f27c55f2c3689d2bebdc11684621e7b Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 24 Apr 2024 15:50:59 -0700 Subject: Change troop-number and troop-allegiance references to just number and allegiance --- src/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/index.js') 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)); }) ); -- cgit v1.2.3