Allow selecting off-board units
This commit is contained in:
parent
0af0271076
commit
484100727f
@ -158,6 +158,10 @@ function hasPreviousMoveInHistory(counter) {
|
||||
return 'previous' in counter.dataset;
|
||||
}
|
||||
|
||||
function selectOffBoard() {
|
||||
this.classList.contains(soldier.getSelectedClass()) ? unSelect() : select(this);
|
||||
}
|
||||
|
||||
export function getUnits() {
|
||||
return soldier.getAllCounters(svg);
|
||||
}
|
||||
@ -177,6 +181,8 @@ export function setSelectCallback(callback) {
|
||||
export function start(el) {
|
||||
svg = el;
|
||||
|
||||
getUnits(svg).forEach(unit => unit.addEventListener('click', selectOffBoard));
|
||||
|
||||
getCells(svg).forEach(cell => {
|
||||
cell.addEventListener('click', e => {
|
||||
const occupant = getCellOccupant(cell);
|
||||
@ -186,6 +192,7 @@ export function start(el) {
|
||||
getHex(cell).after(toPlace);
|
||||
} else if (toPlace && !occupant) {
|
||||
soldier.place(svg, toPlace, cell);
|
||||
toPlace.removeEventListener('click', selectOffBoard);
|
||||
placing.push(toPlace);
|
||||
getLockedSightLine(svg) ? updateSightLine(cell) : clearSightLine();
|
||||
} else if (toPlace && occupant) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user