index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 25 | ||||
-rw-r--r-- | src/modules/scenario.js | 12 | ||||
-rw-r--r-- | src/radial.js | 2 |
3 files changed, 12 insertions, 27 deletions
diff --git a/src/index.js b/src/index.js index e6efe5f..84f8dd4 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,12 @@ const mapPlaceholder = document.querySelector('.map-placeholder'), 6: 'six' }, + attrNames = { + 'primary-weapon': 'weapon', + 'troop-number': 'number', + 'squad-number': 'squad' + }, + toggleContentVis = (function () { document.querySelector('#content').style.minWidth = this.checked ? '' : 0; @@ -55,19 +61,12 @@ async function buildScenario(req) { gameboard.stop(); recordSheet.stop(); - // const svg = scenarioTemplate.querySelector('svg').cloneNode(true); - - const svg = document.querySelector('object').contentDocument.querySelector('svg'); + const map = document.querySelector('object').contentDocument.querySelector('svg'); + const template = scenarioTemplate.querySelector('svg').cloneNode(true); + map.replaceWith(template); - await build(svg, req); + await build(template, req); const scenario = await req; - - const attrNames = { - 'primary-weapon': 'weapon', - 'troop-number': 'number', - 'squad-number': 'squad' - }; - const scenarioUnits = scenario.querySelectorAll('svg g.counter'); scenarioUnits.forEach(cntr => { @@ -81,8 +80,8 @@ async function buildScenario(req) { mapResourceEl.style.opacity = 1; mapPlaceholder.style.opacity = 0; - panzoom.start(svg); - gameboard.start(svg); + panzoom.start(template); + gameboard.start(template); // recordSheet.start(svg.querySelector('.start-locations'), gameboard.getUnits()); recordSheet.start(null, scenarioUnits); diff --git a/src/modules/scenario.js b/src/modules/scenario.js index c15f500..039801d 100644 --- a/src/modules/scenario.js +++ b/src/modules/scenario.js @@ -70,9 +70,6 @@ export async function build(svg, request) { return acc; }, {}); - console.log('refs', refs); - console.log(counters.split('/').pop().split('-').shift()); - const hashedFilenames = { 'counters.svg': counters, 'mapsheets.svg': mapsheets @@ -98,13 +95,6 @@ export async function build(svg, request) { }); }); - // scenario.querySelectorAll('use.mapsheet').forEach(el => - // gb.querySelector('#background').after(svg.ownerDocument.importNode(el, true)) - //); - - // startLocs.querySelectorAll('.counter').forEach(el => console.log(el)); - //console.log(startLocs); - //if (startLocs) grid.before(svg.ownerDocument.importNode(startLocs, true)); const scenarioGrid = scenario.querySelector('.grid'); @@ -113,8 +103,6 @@ export async function build(svg, request) { grid.replaceWith(svg.ownerDocument.importNode(scenarioGrid, true)); } - //defs.replaceWith(scenario.querySelector('defs')); - await loadScript(scenario, svg, 'radial') return loadScript(scenario, svg, 'map'); } diff --git a/src/radial.js b/src/radial.js index e7811fd..501a0a4 100644 --- a/src/radial.js +++ b/src/radial.js @@ -595,8 +595,6 @@ const mapsheets = [mapsheet1, mapsheet2, mapsheet3, mapsheet4].reduce((acc, ms) return acc; }, {}); -console.log(mapsheets); - let sheets = []; const scenarioMapsheets = document.querySelectorAll('.grid [class^="mapsheet"]'); |