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/record_sheet.js | |
parent | 3c0e59f68ee061abc98dafa07301bd54005e94dc (diff) |
Add troop number and squad number when creating counters
Diffstat (limited to 'src/modules/record_sheet.js')
-rw-r--r-- | src/modules/record_sheet.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index 5f14852..0e26155 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -63,15 +63,19 @@ function createWeaponIcon(type) { function createRecord(unit) { const { dataset: { allegiance, number, squad }} = unit, - primaryWeapon = unit.querySelector('.primary-weapon'), - pw = primaryWeapon.getAttributeNS(null, 'href').split('#').pop() || 'rifle', + + pw = unit.classList && unit.classList.contains('counter') + ? unit.querySelector('.primary-weapon').getAttributeNS(null, 'href').split('#').pop() + : unit.dataset.weapon || 'rifle', + div = document.createElement('soldier-record-block'), spans = Array(6).fill('span').map(t => document.createElement(t)), [tn, sn, pwt, pwd, pwrs, pwrl] = spans; div.classList.add('soldier-record'); - if (unit.classList.contains('selected')) div.classList.add('selected'); + if (unit.classList && unit.classList.contains('selected')) div.classList.add('selected'); div.dataset.number = number; + div.dataset.squad = squad; div.dataset.allegiance = allegiance; tn.setAttribute('slot', 'troop-number'); |