Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-07-02 17:18:45 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-07-02 17:18:45 -0700
commit5f17d5d786af74bb7b6bd6f99bcd0ccfab4fc9d5 (patch)
treeb0bc7678fae2f79799f5aee4d99d872bb7f58673 /src/modules/game
parent3c0e59f68ee061abc98dafa07301bd54005e94dc (diff)
Add troop number and squad number when creating counters
Diffstat (limited to 'src/modules/game')
-rw-r--r--src/modules/game/soldier.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js
index 7a3ffaa..3ac7b37 100644
--- a/src/modules/game/soldier.js
+++ b/src/modules/game/soldier.js
@@ -57,18 +57,28 @@ function createTrace(previous, current, selected) {
}
export function createCounter(selected, weapon = 'rifle') {
- const use = document.createElementNS(svgns, 'use');
const g = document.createElementNS(svgns, 'g');
+ const weaponCounter = document.createElementNS(svgns, 'use');
const assignedWeapon = isRecord(selected) ? extractWeaponFromRecord(selected) : weapon;
+ const troopNum = document.createElementNS(svgns, 'use');
+ const squadNum = document.createElementNS(svgns, 'use');
- use.setAttributeNS(null, 'href', `../../${counters}#${assignedWeapon}`);
- use.classList.add('primary-weapon');
+ weaponCounter.setAttributeNS(null, 'href', `../../${counters}#${assignedWeapon}`);
+ weaponCounter.classList.add('primary-weapon');
+
+ troopNum.setAttributeNS(null, 'href', `../../${counters}#number-${selected.dataset.number}`);
+ troopNum.classList.add('troop-number');
+
+ squadNum.setAttributeNS(null, 'href', `../../${counters}#number-${selected.dataset.squad}`);
+ squadNum.classList.add('squad-number');
g.classList.add('counter');
g.dataset.allegiance = selected.dataset.allegiance;
g.dataset.number = selected.dataset.number;
g.dataset.squad = selected.dataset.squad;
- g.appendChild(use);
+ g.appendChild(weaponCounter);
+ g.appendChild(troopNum);
+ g.appendChild(squadNum);
return g;
}