Don't export unnecessary functions

This commit is contained in:
Catalin Constantin Mititiuc 2024-05-22 09:26:32 -07:00
parent 556abf9bbf
commit 8667e7e6da
2 changed files with 32 additions and 36 deletions

View File

@ -174,8 +174,29 @@ function selectOffBoard() {
Observable.notify('select', this); Observable.notify('select', this);
} }
export function getUnits() { function select(data) {
return soldier.getAllCounters(svg); 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) { export function start(el) {
@ -279,29 +300,8 @@ export function start(el) {
console.log('gameboard.js loaded'); console.log('gameboard.js loaded');
} }
export function select(data) { export function getUnits() {
if (!data) return; return soldier.getAllCounters(svg);
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 clearFiringArcs(allegiance) { export function clearFiringArcs(allegiance) {
@ -309,12 +309,8 @@ export function clearFiringArcs(allegiance) {
} }
export function toggleProne() { export function toggleProne() {
const selected = getSelected(), const selected = getSelected();
isOnBoard = selected && selected.parentElement.hasAttribute('data-x'); if (selected) soldier.toggleProne(selected);
if (selected && isOnBoard) {
soldier.toggleProne(selected);
}
} }
export function toggleFiringArcVisibility() { export function toggleFiringArcVisibility() {

View File

@ -137,11 +137,7 @@ function select(data) {
record.classList.add('selected'); record.classList.add('selected');
} }
export function getSelected() { function endMove() {
return document.querySelector('.soldier-record.selected');
}
export function endMove() {
const selected = getSelected(); const selected = getSelected();
if (selected) { if (selected) {
@ -151,6 +147,10 @@ export function endMove() {
deselect(); deselect();
} }
export function getSelected() {
return document.querySelector('.soldier-record.selected');
}
export function start(startLoc, units) { export function start(startLoc, units) {
clear(); clear();
const forces = createRecords(units); const forces = createRecords(units);