Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/game')
-rw-r--r--src/modules/game/soldier.js18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js
index 12adf6b..f9c67db 100644
--- a/src/modules/game/soldier.js
+++ b/src/modules/game/soldier.js
@@ -9,16 +9,9 @@ function traceSelector(counter) {
}
function getCellPosition(cell) {
- let pt = new DOMPoint(0, 0),
- transform = getComputedStyle(cell).transform.match(/-?\d+\.?\d*/g),
- mtx = new DOMMatrix(transform);
- pt = pt.matrixTransform(mtx);
+ const [x, y] = cell.getAttributeNS(null, 'transform').match(/-?\d+\.?\d*/g);
- transform = getComputedStyle(cell.parentElement).transform.match(/-?\d+\.?\d*/g);
- mtx = new DOMMatrix(transform);
- pt = pt.matrixTransform(mtx);
-
- return pt;
+ return { x, y };
}
function getClones(svg, counter) {
@@ -35,12 +28,9 @@ function addMoveToHistory(selected) {
}
function updatePlacement(cell, selected, clone) {
- const prevCoords = [
- clone.parentElement.dataset.x,
- clone.parentElement.parentElement.dataset.y
- ]
+ const { q, r, s, t } = clone.parentElement.dataset;
- selected.dataset.previous = prevCoords;
+ selected.dataset.previous = [q, r, s, t];
cell.appendChild(selected);
Array.from(selected.children).forEach(n => {