index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-07-02 17:18:45 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-07-02 17:18:45 -0700 |
commit | 5f17d5d786af74bb7b6bd6f99bcd0ccfab4fc9d5 (patch) | |
tree | b0bc7678fae2f79799f5aee4d99d872bb7f58673 /src/modules/game/soldier.js | |
parent | 3c0e59f68ee061abc98dafa07301bd54005e94dc (diff) |
Add troop number and squad number when creating counters
Diffstat (limited to 'src/modules/game/soldier.js')
-rw-r--r-- | src/modules/game/soldier.js | 18 |
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; } |