Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-05-22 09:12:47 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-05-22 09:12:47 -0700
commit98e4fd58d8c222652f3a5bd1d8a76f7618824e17 (patch)
tree12f1486c73f39fa5190dd938f99efb0257094761 /src/index.js
parent7395df376deac945fa8f10cbc05c318b1d8dc931 (diff)
Use observable for end move and prone flag
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/index.js b/src/index.js
index 298f961..53cbf2e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,6 +2,7 @@ import * as panzoom from './modules/pan-zoom.js';
import * as gameboard from './modules/gameboard.js';
import * as recordSheet from './modules/record_sheet.js';
import * as mapSelectDialog from './modules/map_select_dialog.js';
+import { Observable } from './modules/observable.js';
globalThis.svgns = 'http://www.w3.org/2000/svg';
@@ -131,7 +132,7 @@ document.querySelectorAll('.end-turn').forEach(el =>
clearMoveEndedIndicators(opponentRecords);
gameboard.clearFiringArcs(opponent);
- gameboard.select(firstOpponentRecord);
+ Observable.notify('select', firstOpponentRecord);
})
);
@@ -157,12 +158,11 @@ gameboard.setDistanceCallback((count = '-') => {
distanceOutput.style.display = count === '-' ? 'none' : 'block';
});
-gameboard.setProneFlagCallback(checked => proneToggle.checked = checked);
+Observable.subscribe('proneflag', checked => proneToggle.checked = checked);
-document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click', () => {
- recordSheet.endMove();
- gameboard.endMove();
-}));
+document.querySelectorAll('.end-move').forEach(el =>
+ el.addEventListener('click', () => Observable.notify('endmove'))
+);
document.querySelector('#fullscreen').addEventListener('click', () => {
if (!document.fullscreenElement) {