From 2ef091909766974368ac6916baeea04c42c58644 Mon Sep 17 00:00:00 2001 From: tmont Date: Thu, 18 Mar 2021 21:59:34 -0700 Subject: [PATCH] link to automatically set char stats from levels --- web/static/saga.js | 15 +++++++++++++++ web/views/levels.pug | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/web/static/saga.js b/web/static/saga.js index 05f79f2..c6dc5a6 100644 --- a/web/static/saga.js +++ b/web/static/saga.js @@ -346,6 +346,21 @@ }); }); + $('.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]); + break; + } + }); + }); + const $enemyInfoModal = $('#enemy-info-modal'); if ($enemyInfoModal.length) { let rowData; 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)