From b14c070373dadc8a16afec7a0797a53c9515ccc2 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Fri, 9 Aug 2024 15:38:12 -0700
Subject: Change elevation level when revealing counter on map
---
src/modules/gameboard.js | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
(limited to 'src/modules/gameboard.js')
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 4407577..0bde2df 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -182,10 +182,16 @@ function selectOffBoard() {
Observable.notify('select', this, { revealRecord: true });
}
+function viewElevation(elevationLevel) {
+ const gb = svg.querySelector('.gameboard');
+ gb.dataset.viewElevation = elevationLevel;
+}
+
function panMapToCounter(counter) {
const gb = svg.querySelector('.gameboard');
if (gb.contains(counter)) {
+ Observable.notify('viewElevation', counter.parentElement.dataset.t);
const counterRect = counter.getBoundingClientRect();
const mapRect = svg.parentNode.defaultView.frameElement.getBoundingClientRect();
@@ -400,8 +406,6 @@ export function start(el) {
//
const trooper1 = soldier.createCounter({ dataset: { allegiance: 'attacker', number: 1, squad: 1 }}, 'blazer');
-
-
soldier.place(svg, trooper1, getCell(-3, 9, -6, 0));
soldier.place(
@@ -410,14 +414,6 @@ export function start(el) {
getCell(1, -8, 7, 0)
);
- const t1Rect = trooper1.getBoundingClientRect();
-
- setTimeout(() => {
- const t1Rect = trooper1.getBoundingClientRect();
- console.log('trooper', trooper1, trooper1.getBoundingClientRect());
-
- }, 10);
-
// Add some counters in an unoccupied cell
//const countersCell = getCell(-1, 1, 0, 0);
@@ -447,6 +443,7 @@ export function start(el) {
Observable.subscribe('select', select);
Observable.subscribe('endmove', endMove);
+ Observable.subscribe('viewElevation', viewElevation);
console.log('gameboard.js loaded');
}
@@ -454,6 +451,7 @@ export function start(el) {
export function stop() {
Observable.unsubscribe('select', select);
Observable.unsubscribe('endmove', endMove);
+ Observable.unsubscribe('viewElevation', viewElevation);
}
export function getUnits() {
--
cgit v1.2.3