From 8667e7e6da29e5615c5e3b1808d36490cf4c4ba7 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Wed, 22 May 2024 09:26:32 -0700
Subject: Don't export unnecessary functions
---
src/modules/gameboard.js | 58 +++++++++++++++++++++------------------------
src/modules/record_sheet.js | 10 ++++----
2 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 4b7d87b..8b64617 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -174,8 +174,29 @@ function selectOffBoard() {
Observable.notify('select', this);
}
-export function getUnits() {
- return soldier.getAllCounters(svg);
+function select(data) {
+ if (!data) return;
+
+ const counter = soldier.getCounter(svg, data) || soldier.createCounter(data);
+ const isSelected = counter.classList.contains(soldier.getSelectedClass());
+
+ deselect();
+
+ if (isSelected) return;
+
+ counter.classList.add(soldier.getSelectedClass());
+ firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
+ Observable.notify('proneflag', soldier.hasProne(counter));
+ placing.push(counter);
+}
+
+function endMove() {
+ const selected = getSelected();
+
+ if (selected) {
+ soldier.endMove(svg, selected);
+ deselect();
+ }
}
export function start(el) {
@@ -279,29 +300,8 @@ export function start(el) {
console.log('gameboard.js loaded');
}
-export function select(data) {
- if (!data) return;
-
- const counter = soldier.getCounter(svg, data) || soldier.createCounter(data);
- const isSelected = counter.classList.contains(soldier.getSelectedClass());
-
- deselect();
-
- if (isSelected) return;
-
- counter.classList.add(soldier.getSelectedClass());
- firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path'));
- Observable.notify('proneflag', soldier.hasProne(counter));
- placing.push(counter);
-}
-
-export function endMove() {
- const selected = getSelected();
-
- if (selected) {
- soldier.endMove(svg, selected);
- deselect();
- }
+export function getUnits() {
+ return soldier.getAllCounters(svg);
}
export function clearFiringArcs(allegiance) {
@@ -309,12 +309,8 @@ export function clearFiringArcs(allegiance) {
}
export function toggleProne() {
- const selected = getSelected(),
- isOnBoard = selected && selected.parentElement.hasAttribute('data-x');
-
- if (selected && isOnBoard) {
- soldier.toggleProne(selected);
- }
+ const selected = getSelected();
+ if (selected) soldier.toggleProne(selected);
}
export function toggleFiringArcVisibility() {
diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js
index b180a8e..f13f5f8 100644
--- a/src/modules/record_sheet.js
+++ b/src/modules/record_sheet.js
@@ -137,11 +137,7 @@ function select(data) {
record.classList.add('selected');
}
-export function getSelected() {
- return document.querySelector('.soldier-record.selected');
-}
-
-export function endMove() {
+function endMove() {
const selected = getSelected();
if (selected) {
@@ -151,6 +147,10 @@ export function endMove() {
deselect();
}
+export function getSelected() {
+ return document.querySelector('.soldier-record.selected');
+}
+
export function start(startLoc, units) {
clear();
const forces = createRecords(units);
--
cgit v1.2.3