From 3c0e59f68ee061abc98dafa07301bd54005e94dc Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Tue, 2 Jul 2024 15:52:38 -0700
Subject: Create counters with assigned weapons
---
src/modules/game/soldier.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'src/modules/game/soldier.js')
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js
index fc3d113..7a3ffaa 100644
--- a/src/modules/game/soldier.js
+++ b/src/modules/game/soldier.js
@@ -1,4 +1,5 @@
import counters from './assets/images/counters.svg';
+import { extractWeaponFromRecord, isRecord } from '../record_sheet.js';
const selectedClass = 'selected';
@@ -58,8 +59,11 @@ function createTrace(previous, current, selected) {
export function createCounter(selected, weapon = 'rifle') {
const use = document.createElementNS(svgns, 'use');
const g = document.createElementNS(svgns, 'g');
- use.setAttributeNS(null, 'href', `../../${counters}#${weapon}`);
+ const assignedWeapon = isRecord(selected) ? extractWeaponFromRecord(selected) : weapon;
+
+ use.setAttributeNS(null, 'href', `../../${counters}#${assignedWeapon}`);
use.classList.add('primary-weapon');
+
g.classList.add('counter');
g.dataset.allegiance = selected.dataset.allegiance;
g.dataset.number = selected.dataset.number;
--
cgit v1.2.3