Get sight line working again
This commit is contained in:
parent
2499b8c268
commit
76eb662bcd
@ -125,7 +125,7 @@ function updateSightLine(cell) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drawSightLine(sourceCell, targetCell) {
|
function drawSightLine(sourceCell, targetCell) {
|
||||||
calcSightLine(sourceCell, targetCell)
|
calcSightLine(sourceCell, targetCell);
|
||||||
const line = sightLine.create(getCellPosition(sourceCell), getCellPosition(targetCell));
|
const line = sightLine.create(getCellPosition(sourceCell), getCellPosition(targetCell));
|
||||||
svg.querySelector('.gameboard').appendChild(line);
|
svg.querySelector('.gameboard').appendChild(line);
|
||||||
}
|
}
|
||||||
@ -239,6 +239,8 @@ export function start(el) {
|
|||||||
}
|
}
|
||||||
frontmostStore.delete(child);
|
frontmostStore.delete(child);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getActiveSightLine(svg) && clearSightLine();
|
||||||
console.log('object', svg.querySelectorAll('.hover'));
|
console.log('object', svg.querySelectorAll('.hover'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -319,8 +321,17 @@ export function start(el) {
|
|||||||
|
|
||||||
targetCell.classList.contains('frontmost') ? frontmostStore.get(e.target.closest('.frontmost > *')).classList.add('hover') : targetCell.classList.add('hover');
|
targetCell.classList.contains('frontmost') ? frontmostStore.get(e.target.closest('.frontmost > *')).classList.add('hover') : targetCell.classList.add('hover');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selected = getSelected();
|
||||||
|
|
||||||
|
if (selected && targetCell && svg.querySelector('.grid').contains(selected) && !getLockedSightLine(svg) && selected.parentElement !== frontmost) {
|
||||||
|
clearSightLine();
|
||||||
|
drawSightLine(selected.parentElement, grid.querySelector('.hover'));
|
||||||
|
} else {
|
||||||
|
getActiveSightLine(svg) && clearSightLine();
|
||||||
|
}
|
||||||
//const counter = targetCell && targetCell.querySelector('.counter');
|
//const counter = targetCell && targetCell.querySelector('.counter');
|
||||||
//console.log('pointerover', 'targetCell', targetCell);
|
//console.log('pointerover', 'targetCell', targetCell);
|
||||||
|
|
||||||
@ -347,6 +358,7 @@ export function start(el) {
|
|||||||
|
|
||||||
//targetCell && targetCell.classList.add('hover');
|
//targetCell && targetCell.classList.add('hover');
|
||||||
|
|
||||||
|
|
||||||
//if (targetCell && !targetCell.classList.contains('frontmost')) {
|
//if (targetCell && !targetCell.classList.contains('frontmost')) {
|
||||||
// targetCell.classList.add('hover');
|
// targetCell.classList.add('hover');
|
||||||
// const occupant = targetCell.querySelector('.counter');
|
// const occupant = targetCell.querySelector('.counter');
|
||||||
@ -444,14 +456,26 @@ export function start(el) {
|
|||||||
grid.addEventListener('contextmenu', e => {
|
grid.addEventListener('contextmenu', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
getSelected() ? sightLine.toggleLock(grid.querySelector('.hover')) : clearHexDialog.showModal();
|
const selected = getSelected();
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
if (sightLine.getSightLine()) sightLine.toggleLock(grid.querySelector('.hover'));
|
||||||
|
if (getActiveSightLine(svg)) {
|
||||||
|
clearSightLine();
|
||||||
|
if (selected.parentElement !== frontmost)
|
||||||
|
drawSightLine(selected.parentElement, grid.querySelector('.hover'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clearHexDialog.showModal();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const startingLocations = svg.querySelector('.start-locations');
|
const startingLocations = svg.querySelector('.start-locations');
|
||||||
startingLocations && getUnits(startingLocations).forEach(unit => unit.addEventListener('click', selectOffBoard));
|
startingLocations && getUnits(startingLocations).forEach(unit => unit.addEventListener('click', selectOffBoard));
|
||||||
|
|
||||||
function clickHandler(e) {
|
function clickHandler(e) {
|
||||||
const targetCell = e.target.closest('[data-q][data-r][data-s][data-t]') || frontmostStore.get(e.target.closest('.frontmost > *'));
|
//const targetCell = e.target.closest('[data-q][data-r][data-s][data-t]') || frontmostStore.get(e.target.closest('.frontmost > *'));
|
||||||
|
const targetCell = grid.querySelector('.hover');
|
||||||
const occupant = frontmost.querySelector('.counter');
|
const occupant = frontmost.querySelector('.counter');
|
||||||
let toPlace = placing.pop();
|
let toPlace = placing.pop();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user