Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/gameboard.js140
1 files changed, 0 insertions, 140 deletions
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index 8c91ee5..bd7b765 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -46,17 +46,6 @@ function isMechTemplate(el) {
return el && el.getAttribute('class') === 'mech-template';
}
-//function isClone(counter) {
-// const isClone = counter.classList.contains('clone'),
-// { allegiance: clAl, number: clNum } = counter.dataset;
-//
-// return {
-// of: function ({ dataset: { allegiance, number }}) {
-// return isClone && clAl == allegiance && clNum == number;
-// }
-// };
-//}
-
function getCellPosition(cell) {
const [x, y] = cell.getAttributeNS(null, 'transform').match(/-?\d+\.?\d*/g);
@@ -127,57 +116,6 @@ function drawSightLine(sourceCell, targetCell) {
svg.querySelector('.gameboard').appendChild(line);
}
-//function moveBackOneStepInHistory(counter) {
-// const trace = soldier.getTrace(svg, counter);
-//
-// counter.remove();
-// counter = getCounterAtGridIndex(...counter.dataset.previous.split(','));
-// counter.classList.remove('clone');
-// counter.classList.add(soldier.getSelectedClass());
-//
-// if (!('previous' in counter.dataset)) {
-// trace.remove();
-// } else {
-// const points = trace.getAttribute('points').split(' ');
-// points.pop();
-// trace.setAttributeNS(null, 'points', points.join(' '));
-// }
-//
-// return counter;
-//}
-
-//function clearMoveHistory(clone, counter) {
-// clone.classList.remove('clone');
-// clone.classList.add(soldier.getSelectedClass());
-// counter.remove();
-// counter = clone;
-// soldier.removeClones(svg, counter);
-// soldier.getTrace(svg, counter).remove();
-//
-// return counter;
-//}
-
-//function deleteClone(occupant, counter, cell) {
-// const index = getGridIndex(occupant),
-// trace = soldier.getTrace(svg, counter),
-// pos = getCellPosition(cell),
-// points = trace.getAttribute('points').split(' ').filter(p => p != `${pos.x},${pos.y}`).join(' ');;
-//
-// let current = counter;
-// trace.setAttributeNS(null, 'points', points);
-//
-// while (current.dataset.previous != `${index.q},${index.r},${index.s},${index.t}`) {
-// current = getCounterAtGridIndex(...current.dataset.previous.split(','));
-// }
-//
-// current.dataset.previous = occupant.dataset.previous;
-// occupant.remove();
-//}
-
-//function hasPreviousMoveInHistory(counter) {
-// return 'previous' in counter.dataset;
-//}
-
function selectOffBoard() {
Observable.notify('select', this, { revealRecord: true });
}
@@ -229,7 +167,6 @@ function endMove() {
const selected = getSelected();
if (selected) {
- //soldier.endMove(svg, selected);
deselect();
}
}
@@ -242,8 +179,6 @@ export function start(el) {
// For when the pointer leaves the window
document.querySelector('object').addEventListener('pointerout', e => {
if (clearHexDialog.open) return;
- //console.log('object pointerout');
- //console.log('Left map... CLEARING HOVERS');
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
[...frontmost.children].forEach(child => {
@@ -263,7 +198,6 @@ export function start(el) {
// Pointer moves outside the edge of the grid
if (!targetCell) {
- //console.log('No target cell... CLEARING HOVERS');
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
[...frontmost.children].forEach(child => {
@@ -284,7 +218,6 @@ export function start(el) {
// 's contents that is in frontmost, whose parent cell is not already highlighted
!(targetCell.classList.contains('frontmost') && frontmostStore.get(e.target.closest('.frontmost > *')).classList.contains('hover'))
].every(e => e)) {
- //console.log('Target cell missing hover... CLEARING HOVERS AND ADDING TO TARGET CELL');
svg.querySelectorAll('.hover').forEach(el => el.classList.remove('hover'));
if (placing[0]?.getAttributeNS(null, 'class') === 'mech-template') {
@@ -325,8 +258,6 @@ export function start(el) {
} else {
getActiveSightLine(svg) && clearSightLine();
}
-
- //console.log('frontmost contents', frontmost.children);
});
grid.addEventListener('click', clickHandler);
@@ -394,77 +325,6 @@ export function start(el) {
const selected = getSelected();
}
- // debug //
- // Add a trooper counter
- //const defender = { dataset: { allegiance: 'defender', number: 1, squad: 2 }};
- //const cell2 = getCell(-5, 10, -5, 0);
- //frontmost.setAttributeNS(null, 'transform', cell2.getAttributeNS(null, 'transform'));
- //const trooper2 = soldier.createCounter(defender, 'gl');
- //frontmostStore.set(trooper2, cell2);
- //frontmost.append(trooper2);
- //cell2.classList.add('hover');
- //
-
- ['lmg', 'mmg', 'hmg', 'splaser', 'hsplaser', 'mpppc'].forEach((w, i) => {
- soldier.place(
- svg,
- soldier.createCounter({ dataset: { allegiance: 'attacker', number: i + 1, squad: 1 }}, w),
- getCell(-3 - i, 9, -6 + i, 0)
- )
- });
-
- ['srm', 'hsrm', 'law', 'gl', 'autogl', 'lrrifle'].forEach((w, i) => {
- soldier.place(
- svg,
- soldier.createCounter({ dataset: { allegiance: 'attacker', number: i + 1, squad: 2 }}, w),
- getCell(-2 - i, 8, -6 + i, 0)
- )
- });
-
- ['satchelcharge', 'grenade', 'nonlethalhand', 'lethalhand', 'flamer', 'hflamer', 'inferno'].forEach((w, i) => {
- soldier.place(
- svg,
- soldier.createCounter({ dataset: { allegiance: 'attacker', number: i + 1, squad: 3 }}, w),
- getCell(-2 - i, 7, -5 + i, 0)
- )
- });
- //const weapon = 'mpppc';
- //const trooper1 = soldier.createCounter({ dataset: { allegiance: 'attacker', number: 1, squad: 1 }}, weapon);
- //soldier.place(svg, trooper1, getCell(-3, 9, -6, 0));
-
- //soldier.place(
- // svg,
- // soldier.createCounter({ dataset: { allegiance: 'defender', number: 1, squad: 1 }}, 'blazer'),
- // getCell(1, -8, 7, 0)
- //);
-
- // Add some counters in an unoccupied cell
- //const countersCell = getCell(-1, 1, 0, 0);
-
- //const counter = document.createElementNS(svgns, 'use');
- //const name = 'grenade';
- //counter.setAttributeNS(null, 'href', `#counter-${name}`);
- //counter.classList.add(`counter-${name}`);
- //frontmostStore.set(counter, cell2);
- //frontmost.append(counter);
- //arrangeCounters(frontmost)
-
- //counter.addEventListener('click', e => {
- // e.stopPropagation()
- // const container = counter.parentElement;
- // counter.remove()
- // arrangeCounters(container);
- //});
-
- //setCounter('grenade');
- //setCounter('prone');
- //setCounter('1st-floor');
- //const e = new PointerEvent('click');
- //countersCell.dispatchEvent(e);
- //countersCell.dispatchEvent(e);
- //countersCell.dispatchEvent(e);
- ///////////
-
Observable.subscribe('select', select);
Observable.subscribe('endmove', endMove);
Observable.subscribe('viewElevation', viewElevation);