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-15 14:58:53 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-07-15 14:58:53 -0700 |
commit | 5763dccbde60e29a72cfc5bcac16db6a22edf4e7 (patch) | |
tree | 39d7bf3e51eba4c1480e50599bc198d24e316d6b /src | |
parent | 9b85d20fecd513ccdb33af29cd0cb12f6e1d4595 (diff) |
WIP: Render buildings already in gameboard when scenario is loaded
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/scenario.js | 4 | ||||
-rw-r--r-- | src/radial.js | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/modules/scenario.js b/src/modules/scenario.js index 6ab66db..805d0fe 100644 --- a/src/modules/scenario.js +++ b/src/modules/scenario.js @@ -94,11 +94,15 @@ export async function build(svg, request) { //if (startLocs) grid.before(svg.ownerDocument.importNode(startLocs, true)); const scenarioGrid = scenario.querySelector('.grid'); + const scenarioBuildings = scenario.querySelector('.gameboard .buildings'); if (scenarioGrid) { grid.replaceWith(svg.ownerDocument.importNode(scenarioGrid, true)); } + if (scenarioBuildings) + svg.querySelector('.gameboard .buildings').replaceWith(svg.ownerDocument.importNode(scenarioBuildings, true)); + await loadScript(scenario, svg, 'radial') return loadScript(scenario, svg, 'map'); } diff --git a/src/radial.js b/src/radial.js index b459ad0..09037ab 100644 --- a/src/radial.js +++ b/src/radial.js @@ -197,7 +197,7 @@ function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, features) buildingStructure.setAttributeNS(null, 'transform', transform(x, y)); const [mapsheet] = container.classList; - document.querySelector(`.buildings .${mapsheet}`).appendChild(buildingStructure); + document.querySelector(`.buildings .${mapsheet}`).prepend(buildingStructure); building.elevationLevels.forEach(elevationLevel => { const hexContainer = document.createElementNS(xmlns, 'g'); @@ -399,7 +399,7 @@ sheets = msGrps.map(msG => { }, new Map()); const { q: dq, r: dr, s: ds } = toRad(bld.dataset); - let position // = bld.dataset.rotate ? rotate180({ q: +dq, r: +dr, s: +ds }) : ({ q, r, s }) => ({ q: q + +dq, r: r + +dr, s: s + +ds }); + let position; if (bld.dataset.rotate) position = rotate180({ q: +dq, r: +dr, s: +ds }); @@ -426,7 +426,6 @@ sheets = msGrps.map(msG => { }); }); -const scenarioMapsheets = document.querySelectorAll('.grid [class^="mapsheet"]'); document.querySelectorAll('use[href^="#building"]').forEach(el => el.remove()); let finalGrid = new Map(); |