Web Dev Solutions

Catalin Mititiuc

From 0783d703c1365f3307cb9e780b81f5ef19387bac Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 6 Aug 2024 19:51:22 -0700 Subject: WIP: very rough armor --- public/assets/css/soldier_record_block.css | 37 ++++++ public/assets/css/style.css | 3 + public/assets/images/counters.svg | 12 +- public/assets/images/map4.svg | 7 +- public/assets/images/scenario-dragon_hunting.svg | 36 +++--- .../assets/images/scenario-race_against_time.svg | 137 ++++++++++++++++++--- public/assets/images/scenario-side_show.svg | 2 +- src/modules/gameboard.js | 22 ++-- src/modules/record_sheet.js | 50 +++++++- 9 files changed, 250 insertions(+), 56 deletions(-) diff --git a/public/assets/css/soldier_record_block.css b/public/assets/css/soldier_record_block.css index 5fb8c7c..096a1b2 100644 --- a/public/assets/css/soldier_record_block.css +++ b/public/assets/css/soldier_record_block.css @@ -5,6 +5,9 @@ span { } .physical-status-track { + display: flex; + justify-content: space-between; + align-items: end; text-align: center; } @@ -57,3 +60,37 @@ p { .grenades input:checked + svg circle { fill: gray; } + +[slot="block-number"]:not(:last-of-type) { + display: inline-block; + width: 1.3em; +} + +damage-block.armor span[slot="block-number"] { + border: 1px solid black; + padding: 2px; + border-radius: 50%; + position: relative; +} + +.physical-status-track damage-block:nth-child(1 of .armor) span[slot="block-number"]:hover { + border: 1px solid orangered; + cursor: pointer; +} + +.physical-status-track damage-block:nth-child(1 of .armor) span[slot="block-number"]:hover::before { + content: '๐Ÿก„'; /*<โ‡ฝโญ โฎˆ๐Ÿ ˆ ๐Ÿ œ ๐Ÿก„*/ + position: absolute; + margin-left: -1.5em; +} + +.physical-status-track damage-block:nth-last-child(1 of .armor) span[slot="block-number"]:hover { + border: 1px solid orangered; + cursor: pointer; +} + +.physical-status-track damage-block:nth-last-child(1 of .armor) span[slot="block-number"]:hover::after { + content: '๐Ÿก†'; /* ๐Ÿ Š ๐Ÿก† */ + position: absolute; + margin-left: 1em; +} diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 235fa73..3f6cd88 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -134,6 +134,9 @@ button.set-firing-arc img { white-space: nowrap; background-color: white; transition: transform 0.25s; + user-select: none; + -webkit-user-select: none; + cursor: default; } .soldier-record span[slot] { diff --git a/public/assets/images/counters.svg b/public/assets/images/counters.svg index 8c3e444..487bce0 100644 --- a/public/assets/images/counters.svg +++ b/public/assets/images/counters.svg @@ -105,7 +105,7 @@ - + @@ -115,6 +115,16 @@ + + + + + + + + + + diff --git a/public/assets/images/map4.svg b/public/assets/images/map4.svg index 0113404..d38738c 100644 --- a/public/assets/images/map4.svg +++ b/public/assets/images/map4.svg @@ -55,7 +55,7 @@ - + @@ -117,11 +117,6 @@ - - - - - diff --git a/public/assets/images/scenario-dragon_hunting.svg b/public/assets/images/scenario-dragon_hunting.svg index 40f0a87..2b7e701 100644 --- a/public/assets/images/scenario-dragon_hunting.svg +++ b/public/assets/images/scenario-dragon_hunting.svg @@ -18,49 +18,49 @@ - + - + - + - + - + - + - + @@ -68,49 +68,49 @@ - - + + - - + + - - + + - - + + - + - + - + diff --git a/public/assets/images/scenario-race_against_time.svg b/public/assets/images/scenario-race_against_time.svg index 2aef61c..f6116fb 100644 --- a/public/assets/images/scenario-race_against_time.svg +++ b/public/assets/images/scenario-race_against_time.svg @@ -7,25 +7,25 @@ - + - + - + - + @@ -58,57 +58,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/assets/images/scenario-side_show.svg b/public/assets/images/scenario-side_show.svg index 1769146..ccbafe7 100644 --- a/public/assets/images/scenario-side_show.svg +++ b/public/assets/images/scenario-side_show.svg @@ -63,7 +63,7 @@ - + diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js index 8cb6af1..3741ad2 100644 --- a/src/modules/gameboard.js +++ b/src/modules/gameboard.js @@ -379,17 +379,17 @@ export function start(el) { //cell2.classList.add('hover'); // - soldier.place( - svg, - soldier.createCounter({ dataset: { allegiance: 'attacker', number: 2, squad: 1 }}, 'hsplaser'), - getCell(-2, 3, -1, 0) - ); - - soldier.place( - svg, - soldier.createCounter({ dataset: { allegiance: 'attacker', number: 2, squad: 5 }}, 'rifle'), - getCell(-3, 3, 0, 0) - ); + //soldier.place( + // svg, + // soldier.createCounter({ dataset: { allegiance: 'attacker', number: 2, squad: 1 }}, 'hsplaser'), + // getCell(-2, 3, -1, 0) + //); + // + //soldier.place( + // svg, + // soldier.createCounter({ dataset: { allegiance: 'attacker', number: 2, squad: 5 }}, 'rifle'), + // getCell(-3, 3, 0, 0) + //); // Add some counters in an unoccupied cell //const countersCell = getCell(-1, 1, 0, 0); diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index e5be4bf..34ffe80 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -38,11 +38,17 @@ const weapons = { shortRange: '1-44', longRange: '45-108' }, - gl: { + smggl: { name: 'SMG w/Grenade Launcher', damage: '4/2/1 L', shortRange: '1-10', longRange: '11-24' + }, + riflegl: { + name: 'Rifle w/Grenade Launcher', + damage: '4/2/1 L', + shortRange: '1-10', + longRange: '11-24' } } @@ -121,6 +127,48 @@ function createRecord(unit) { spans.forEach(el => div.appendChild(el)); + if (unit.dataset.armor) { + const s = `damage-block:nth-of-type(n + 1):nth-of-type(-n + ${unit.dataset.armor})`; + const armorBlocks = div.shadowRoot.querySelectorAll(s); + + armorBlocks.forEach(el => { + el.classList.add('armor'); + }); + + const ls = 'damage-block:nth-child(1 of .armor):not(:first-child)'; + const rs = 'damage-block:nth-last-child(1 of .armor):not(:last-child)'; + const moveArmorEl = div.shadowRoot.querySelectorAll(`${ls}, ${rs}`); + + function moveArmorHandler(e) { + e.stopPropagation(); + + this.removeEventListener('click', moveArmorHandler); + if (!this.previousElementSibling.classList.contains('armor')) { + this.previousElementSibling.classList.add('armor'); + this.previousElementSibling.addEventListener('click', moveArmorHandler); + let current = this.nextElementSibling; + while (current.nextElementSibling && current.nextElementSibling.classList.contains('armor')) { + current = current.nextElementSibling; + } + current.classList.remove('armor'); + current.removeEventListener('click', moveArmorHandler); + current.previousElementSibling.addEventListener('click', moveArmorHandler); + } else if (!this.nextElementSibling.classList.contains('armor')) { + this.nextElementSibling.classList.add('armor'); + this.nextElementSibling.addEventListener('click', moveArmorHandler); + let current = this.previousElementSibling; + while (current.previousElementSibling && current.previousElementSibling.classList.contains('armor')) { + current = current.previousElementSibling; + } + current.classList.remove('armor'); + current.removeEventListener('click', moveArmorHandler); + current.nextElementSibling.addEventListener('click', moveArmorHandler); + } + } + + moveArmorEl.forEach(el => el.addEventListener('click', moveArmorHandler)); + } + function makeInactiveDivider(parent) { const div = document.createElement('div'); div.classList.add('inactive-divider'); -- cgit v1.2.3