From 0c1f7e2fde7ed6e05271c8aeb8d4babbf4f2188d Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Sat, 27 Apr 2024 18:28:59 -0700
Subject: Add ability to change maps
---
src/modules/gameboard.js | 16 ++++++++--------
src/modules/record_sheet.js | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
(limited to 'src/modules')
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 9f8723e..25db4ad 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -19,14 +19,14 @@ function getCellOccupant(cell) {
}
function getCells(svg) {
- return svg.querySelectorAll('g[data-y] > g[data-x]');
+ return svg.querySelectorAll('g.grid > g[data-y] > g[data-x]');
}
function getLockedSightLine(svg) {
return svg.querySelector('line.sight-line:not(.active)');
}
-function getSightLine(svg) {
+export function getSightLine(svg) {
return svg.querySelector('line.sight-line');
}
@@ -63,7 +63,7 @@ function getCellPosition(cell) {
}
function getCell(x, y) {
- return svg.querySelector(`g[data-y="${y}"] > g[data-x="${x}"]`);
+ return svg.querySelector(`g.grid > g[data-y="${y}"] > g[data-x="${x}"]`);
}
function getCounterAtGridIndex(x, y) {
@@ -85,7 +85,7 @@ function updateSightLine(cell) {
{ dataset: { x: tX }, parentElement: { dataset: { y: tY }}} = sightLine.getLockTarget();
const selector = sightLine.calcIndexes(+sX, +sY, +tX, +tY)
- .map(([x, y]) => `g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`)
+ .map(([x, y]) => `g.grid g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`)
.join(', ');
const hexes = svg.querySelectorAll(selector);
@@ -99,7 +99,7 @@ function drawSightLine(sourceCell, targetCell) {
{ dataset: { x: tX }, parentElement: { dataset: { y: tY }}} = targetCell;
const selector = sightLine.calcIndexes(+sX, +sY, +tX, +tY)
- .map(([x, y]) => `g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`)
+ .map(([x, y]) => `g.grid g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`)
.join(', ');
const hexes = svg.querySelectorAll(selector);
@@ -277,9 +277,9 @@ export function start(el) {
});
// debug
- const c = soldier.getCounter(svg, { dataset: { allegiance: 'davion', number: '1' }});
- soldier.place(svg, c, getCell(17, 25));
- select(c);
+ // const c = soldier.getCounter(svg, { dataset: { allegiance: 'davion', number: '1' }});
+ // soldier.place(svg, c, getCell(17, 25));
+ // select(c);
}
export function select(selected) {
diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js
index 99af18f..e5e8de6 100644
--- a/src/modules/record_sheet.js
+++ b/src/modules/record_sheet.js
@@ -14,9 +14,9 @@ export function getSelected() {
export function select(data) {
const selector =
- `#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]`
+ `#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]`
- unSelect();
+ unSelect();
document.querySelector(selector).classList.add('selected');
document.getElementById('toggle-prone-counter').checked = data.prone;
}
--
cgit v1.2.3