Web Dev Solutions

Catalin Mititiuc

From a3bf726e40fe4ed529bdefa83c977af4b72791a9 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 30 Apr 2024 21:10:11 -0700 Subject: Allow placing a counter that doesn't already exist --- src/modules/game/soldier.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/modules/game/soldier.js') diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js index 8e2725d..1555c19 100644 --- a/src/modules/game/soldier.js +++ b/src/modules/game/soldier.js @@ -63,6 +63,18 @@ function createTrace(previous, current, selected) { return trace; } +export function createCounter(selected) { + const use = document.createElementNS(svgns, 'use'); + const g = document.createElementNS(svgns, 'g'); + use.setAttributeNS(null, 'href', `#t-${selected.dataset.number}`); + g.classList.add('counter'); + g.dataset.allegiance = selected.dataset.allegiance; + g.dataset.number = selected.dataset.number; + g.appendChild(use); + + return g; +} + export function handleTrace(svg, selected, clone, current) { let trace = getTrace(svg, selected); -- cgit v1.2.3