diff --git a/web/static/saga.js b/web/static/saga.js index 05f79f2..3bb65aa 100644 --- a/web/static/saga.js +++ b/web/static/saga.js @@ -19,6 +19,14 @@ sameSite: 'strict', }); } + + const stats = [ + charStats.power || '?', + charStats.guard || '?', + charStats.magic || '?', + charStats.speed || '?', + ] + $('.char-stats-display').text('[' + stats.join('/') + ']'); }; window.saga = { @@ -261,6 +269,7 @@ checkLocations(); checkApprentices(); checkCharStats(); + onCharStatChange(); window.saga.sortData(); window.saga.filterApprentices(); window.saga.filterLocations(); @@ -314,8 +323,6 @@ } }); - update(); - // scale all enemy images to fit in a 64x64 square $('.enemy-sprite').each((i, el) => { const $el = $(el); @@ -346,6 +353,24 @@ }); }); + $('.apply-level-stats').on('click', (e) => { + e.preventDefault(); + const data = $(e.target).data(); + Object.keys(data).forEach((stat) => { + switch (stat) { + case 'power': + case 'guard': + case 'magic': + case 'speed': + $(`#char-${stat}`).val(data[stat]); + window.saga.updateCharStat(stat, Number(data[stat])); + break; + } + }); + + onCharStatChange(); + }); + const $enemyInfoModal = $('#enemy-info-modal'); if ($enemyInfoModal.length) { let rowData; @@ -707,4 +732,6 @@ }); }); } + + update(); }(window)); diff --git a/web/views/levels.pug b/web/views/levels.pug index 2b170e4..037d879 100644 --- a/web/views/levels.pug +++ b/web/views/levels.pug @@ -26,7 +26,20 @@ block tab-content while level < 80 mixin calcCharStats(char) - code= char.initial.map((x, i) => Math.min(i < 4 ? 999 : 255, x + (char.level[i] * (level - 1)))).join('/') + - const values = char.initial.map((x, i) => Math.min(i < 4 ? 999 : 255, x + (char.level[i] * (level - 1)))) + code: a.apply-level-stats( + href="#" + data-hp=values[0] + data-mp=values[1] + data-power=values[2] + data-guard=values[3] + data-magic=values[4] + data-speed=values[5] + ) + = values.slice(0, 2).join('/') + = ' ' + = values.slice(2).join('/') + tr td= ++level td: +calcCharStats(esuna) diff --git a/web/views/master.pug b/web/views/master.pug index b103407..a2a67d8 100644 --- a/web/views/master.pug +++ b/web/views/master.pug @@ -47,8 +47,9 @@ html li.nav-item: a.nav-link(href="/accessories" class=(context === 'accessories' ? 'active' : '')) Accessories li.nav-item: a.nav-link(href="/exp" class=(context === 'exp' ? 'active' : '')) Experience li.nav-item: a.nav-link(href="/levels" class=(context === 'levels' ? 'active' : '')) Levels - div - button.btn.btn-secondary.btn-sm(data-toggle="modal" data-target="#char-stats-modal") Character stats… + div: button.btn.btn-secondary.btn-sm(data-toggle="modal" data-target="#char-stats-modal") + | Set character stats + small.ml-1: tt.char-stats-display div.tab-content div.tab-pane.show.active.mt-2 block tab-content