Web Dev Solutions

Catalin Mititiuc

From 5f17d5d786af74bb7b6bd6f99bcd0ccfab4fc9d5 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 2 Jul 2024 17:18:45 -0700 Subject: Add troop number and squad number when creating counters --- src/modules/game/soldier.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/modules/game/soldier.js') 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; } -- cgit v1.2.3