index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/game/soldier.js | 2 | ||||
-rw-r--r-- | src/modules/record_sheet.js | 36 |
2 files changed, 31 insertions, 7 deletions
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js index 1555c19..c5b2323 100644 --- a/src/modules/game/soldier.js +++ b/src/modules/game/soldier.js @@ -43,7 +43,7 @@ function updatePlacement(cell, selected, clone) { selected.dataset.previous = prevCoords; cell.appendChild(selected); - selected.childNodes.forEach(n => { + Array.from(selected.children).forEach(n => { if (n.classList.contains('removed')) { n.remove(); } else if ('preexisting' in n.dataset) { diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index 6909249..4d8aada 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -1,3 +1,24 @@ +const weapons = { + rifle: { + name: 'Rifle', + damage: '4L', + shortRange: '1-27', + longRange: '28-75' + }, + smg: { + name: 'SMG', + damage: '3L', + shortRange: '1-15', + longRange: '16-25' + }, + blazer: { + name: 'Blazer', + damage: '4L', + shortRange: '1-17', + longRange: '18-105' + } +} + function createIcon(number) { const svgns = 'http://www.w3.org/2000/svg'; const [icon, circle, text] = ['svg', 'circle', 'text'].map(t => document.createElementNS(svgns, t)); @@ -17,8 +38,11 @@ function createIcon(number) { return icon; } -function createRecord({ dataset: { allegiance, number }}) { - const div = document.createElement('div', { is: 'soldier-record-block' }), +function createRecord(unit) { + const { dataset: { allegiance, number }} = unit, + primaryWeapon = unit.querySelector('.primary-weapon'), + pw = primaryWeapon.getAttribute('href').replace('#', ''), + div = document.createElement('div', { is: 'soldier-record-block' }), spans = Array(5).fill('span').map(t => document.createElement(t)), [tn, pwt, pwd, pwrs, pwrl] = spans; @@ -30,16 +54,16 @@ function createRecord({ dataset: { allegiance, number }}) { tn.appendChild(createIcon(number)); pwt.setAttribute('slot', 'primary-weapon-type'); - pwt.textContent = 'Rifle'; + pwt.textContent = weapons[pw].name; pwd.setAttribute('slot', 'primary-weapon-damage'); - pwd.textContent = '4L'; + pwd.textContent = weapons[pw].damage; pwrs.setAttribute('slot', 'primary-weapon-range-short'); - pwrs.textContent = '1-27'; + pwrs.textContent = weapons[pw].shortRange; pwrl.setAttribute('slot', 'primary-weapon-range-long'); - pwrl.textContent = '28-75'; + pwrl.textContent = weapons[pw].longRange; spans.forEach(el => div.appendChild(el)); |