Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-07-25 12:25:44 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-07-25 12:25:44 -0700
commitf1d67663dab2fd084c7e3996a83d17e9a6c5e037 (patch)
tree9b084d52077dc518f67c831e73d6bbeacc6ba548 /src/modules/game/soldier.js
parent37b05156c6024926cee7cbf6afc84759f78c8e36 (diff)
WIP: add multiple counters to troopers and cells
Diffstat (limited to 'src/modules/game/soldier.js')
-rw-r--r--src/modules/game/soldier.js8
1 files changed, 6 insertions, 2 deletions
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);
}
}