From f1d67663dab2fd084c7e3996a83d17e9a6c5e037 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Thu, 25 Jul 2024 12:25:44 -0700
Subject: WIP: add multiple counters to troopers and cells
---
src/modules/game/soldier.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'src/modules/game/soldier.js')
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js
index a024f9f..81dce74 100644
--- a/src/modules/game/soldier.js
+++ b/src/modules/game/soldier.js
@@ -34,7 +34,7 @@ function updatePlacement(cell, selected, clone) {
const { q, r, s, t } = clone.parentElement.dataset;
selected.dataset.previous = [q, r, s, t];
- cell.appendChild(selected);
+ placeIn(cell, selected);
Array.from(selected.children).forEach(n => {
if (n.classList.contains('removed')) {
@@ -56,6 +56,10 @@ function createTrace(previous, current, selected) {
return trace;
}
+function placeIn(location, target) {
+ location.querySelector('use[href="#hex"]').after(target);
+}
+
export function createCounter(selected, weapon = 'rifle') {
const g = document.createElementNS(svgns, 'g');
const weaponCounter = document.createElementNS(svgns, 'use');
@@ -126,7 +130,7 @@ export function place(svg, selected, cell) {
handleTrace(svg, selected, clone, getCellPosition(cell));
} else {
selected.removeAttribute('data-x');
- cell.appendChild(selected);
+ placeIn(cell, selected);
}
}
--
cgit v1.2.3