Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-04-27 18:28:59 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-04-27 18:30:03 -0700
commit0c1f7e2fde7ed6e05271c8aeb8d4babbf4f2188d (patch)
treeb15c46880f7aa4e252df7928dbc5a2a2f5eef366 /src/modules
parentce98e325656b8419b80d8c248e0469f3a9708322 (diff)
Add ability to change maps
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/gameboard.js16
-rw-r--r--src/modules/record_sheet.js4
2 files changed, 10 insertions, 10 deletions
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;
}