index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-07-28 12:24:24 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-07-28 12:24:24 -0700 |
commit | 7183511dbf4062535e676bd923856b213d565a52 (patch) | |
tree | 5e2f93756c6477bbb3b651a46dce1fe58f8fec74 /src | |
parent | d2e80b341c323d56c6955decc2c4f8ae38228580 (diff) |
Remove prone toggle
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 15 | ||||
-rw-r--r-- | src/modules/game/soldier.js | 18 | ||||
-rw-r--r-- | src/modules/gameboard.js | 17 |
3 files changed, 8 insertions, 42 deletions
diff --git a/src/index.js b/src/index.js index a951084..fa90d13 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,6 @@ if (window.IS_DEV) { const mapPlaceholder = document.querySelector('.map-placeholder'), distanceOutput = document.getElementById('status'), - proneToggle = document.getElementById('toggle-prone-counter'), contentVisToggleEl = document.querySelector('#edge-inputs input[type="checkbox"].visible'), fileName = localStorage.getItem('map') || 'scenario-side_show', map = scenarios[fileName]?.hashed || `assets/images/${fileName}.svg`, @@ -85,10 +84,10 @@ async function buildScenario(req) { // recordSheet.start(svg.querySelector('.start-locations'), gameboard.getUnits()); recordSheet.start(null, scenarioUnits); - //const [trooper] = gameboard.getUnits(); - //Observable.notify('select', trooper); - //gameboard.setCounter('prone'); - //gameboard.setCounter('1st-floor'); + const [trooper] = gameboard.getUnits(); + Observable.notify('select', trooper); + gameboard.setCounter('prone'); + gameboard.setCounter('1st-floor'); } function updateTurnCounter() { @@ -173,11 +172,6 @@ document.querySelectorAll('#toggle-firing-arc-vis input').forEach(el => el.addEventListener('input', gameboard.toggleFiringArcVisibility) ); -document.getElementById('toggle-prone-counter').addEventListener('input', function () { - const selected = recordSheet.getSelected(); - selected && gameboard.toggleProne(); -}); - document.querySelectorAll('.end-move').forEach(el => el.addEventListener('click', () => Observable.notify('endmove')) ); @@ -313,4 +307,3 @@ dice.forEach(el => { }); Observable.subscribe('distance', distance); -Observable.subscribe('proneflag', checked => proneToggle.checked = checked); diff --git a/src/modules/game/soldier.js b/src/modules/game/soldier.js index 8e5774b..a71ceba 100644 --- a/src/modules/game/soldier.js +++ b/src/modules/game/soldier.js @@ -152,24 +152,6 @@ export function endMove(svg, counter) { removeClones(svg, counter); } -export function hasProne(counter) { - return !!counter.querySelector('[href="#counter-prone"]:not(.removed)'); -} - -export function toggleProne(counter) { - let proneCounter = counter.querySelector('[href="#counter-prone"]'); - - if (!proneCounter) { - proneCounter = document.createElementNS(svgns, 'use'); - proneCounter.setAttributeNS(null, 'href', '#counter-prone'); - counter.appendChild(proneCounter); - } else if ('preexisting' in proneCounter.dataset) { - proneCounter.classList.toggle('removed'); - } else { - proneCounter.remove(); - } -} - export function getSelectedClass() { return selectedClass; } diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js index 5851273..44146f2 100644 --- a/src/modules/gameboard.js +++ b/src/modules/gameboard.js @@ -79,7 +79,6 @@ function getSelected() { function deselect() { const selected = getSelected(); placing = []; - Observable.notify('proneflag', false); if (selected) { selected.classList.remove(soldier.getSelectedClass()); @@ -194,7 +193,6 @@ function select(data) { counter.classList.add(soldier.getSelectedClass()); firingArc.get(svg, counter).forEach(el => el.removeAttribute('clip-path')); - Observable.notify('proneflag', soldier.hasProne(counter)); placing.push(counter); } @@ -266,7 +264,6 @@ export function start(el) { } const selected = getSelected(); - //Observable.notify('proneflag', selected && soldier.hasProne(selected)); } getCells(svg).forEach(cell => { @@ -317,7 +314,6 @@ export function start(el) { } const selected = getSelected(); - Observable.notify('proneflag', selected && soldier.hasProne(selected)); }); cell.addEventListener('dblclick', e => { @@ -406,14 +402,14 @@ export function start(el) { // debug // // Add a trooper counter - //const attacker = { dataset: { allegiance: 'attacker', number: 1, squad: 1 }}; + const attacker = { dataset: { allegiance: 'attacker', number: 1, squad: 1 }}; // const defender = { dataset: { allegiance: 'defender', number: 1, squad: 2 }}; - //const cell = getCell(0, 0, 0, 0); - //const trooper = soldier.createCounter(attacker, 'blazer'); + const cell = getCell(0, 0, 0, 0); + const trooper = soldier.createCounter(attacker, 'blazer'); //const trooperSack = document.createElementNS(svgns, 'g'); //trooperSack.classList.add('cell-contents'); //trooperSack.append(trooper); - //soldier.place(svg, trooper, cell); + soldier.place(svg, trooper, cell); // Add some counters in an unoccupied cell //const countersCell = getCell(-1, 1, 0, 0); @@ -445,11 +441,6 @@ export function clearFiringArcs(allegiance) { firingArc.clear(svg, allegiance); } -export function toggleProne() { - const selected = getSelected(); - if (selected) soldier.toggleProne(selected); -} - export function toggleFiringArcVisibility() { firingArc.toggleVisibility(svg, this.dataset.allegiance); } |