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/radial.js')
-rw-r--r-- | src/radial.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/radial.js b/src/radial.js index 046b608..c6e52a6 100644 --- a/src/radial.js +++ b/src/radial.js @@ -413,7 +413,7 @@ function addElevationClass(element) { return el => element.classList.add(elevationClass(el)); } -function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) { +function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, features) { return buildings.reduce((acc, building) => { const buildingContainer = document.createElementNS(xmlns, 'g'); buildingContainer.classList.add(`building`); @@ -465,17 +465,19 @@ function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) if ((use.classList.contains('doors') || use.classList.contains('door-edges')) && !use.classList.contains('exits')) building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - if (use.classList.contains('furniture')) - building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - buildingStructure.appendChild(use); } - const furnitureEl = furniture && furniture.querySelector(`.${building.type} .furniture`); + const featuresEl = features && features.querySelector(`.${building.type}`); + + for (let child of [...featuresEl.children]) { + if (child.classList.contains('furniture')) + building.elevationLevels.slice(0, -1).forEach(addElevationClass(child)); + + if (child.classList.contains('stairs')) + building.elevationLevels.forEach(addElevationClass(child)); - if (furnitureEl) { - building.elevationLevels.slice(0, -1).forEach(addElevationClass(furnitureEl)); - buildingStructure.appendChild(furnitureEl); + buildingStructure.appendChild(child); } return acc; |