index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/modules/gameboard.js')
-rw-r--r-- | src/modules/gameboard.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js index e8fe575..6359083 100644 --- a/src/modules/gameboard.js +++ b/src/modules/gameboard.js @@ -181,10 +181,10 @@ function hasPreviousMoveInHistory(counter) { } function selectOffBoard() { - Observable.notify('select', this); + Observable.notify('select', this, { revealRecord: true }); } -function select(data) { +function select(data, opts) { const counter = data && (soldier.getCounter(svg, data) || soldier.createCounter(data)); const isSelected = data && data.classList && data.classList.contains('selected'); @@ -192,12 +192,12 @@ function select(data) { if (isSelected || !data) return; - counter.classList.add(soldier.getSelectedClass()); - const gb = svg.querySelector('.gameboard'); - - // TODO check if counter is on board before calling - manualPan(gb, counter); + if (opts?.revealCounter) { + const gb = svg.querySelector('.gameboard'); + if (gb.contains(counter)) manualPan(gb, counter); + } + counter.classList.add(soldier.getSelectedClass()); firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path')); placing.push(counter); } @@ -362,10 +362,10 @@ export function start(el) { if (toPlace === occupant) { Observable.notify('select'); } else { - Observable.notify('select', occupant); + Observable.notify('select', occupant, { revealRecord: true }); } } else if (!toPlace && occupant) { - Observable.notify('select', occupant); + Observable.notify('select', occupant, { revealRecord: true }); } const selected = getSelected(); |