From c25d4241942792d084faf7f8ffc560f0bb5b13cb Mon Sep 17 00:00:00 2001 From: hppeng Date: Sun, 26 Jun 2022 00:43:11 -0700 Subject: [PATCH] HOTFIX: patch str/dex optimizer --- js/builder_graph.js | 1 - js/optimize.js | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/builder_graph.js b/js/builder_graph.js index 899fd6d..a540673 100644 --- a/js/builder_graph.js +++ b/js/builder_graph.js @@ -178,7 +178,6 @@ class ItemInputNode extends InputNode { } compute_func(input_map) { - console.log("Item update...." + Date.now()); const powdering = input_map.get('powdering'); // built on the assumption of no one will type in CI/CR letter by letter diff --git a/js/optimize.js b/js/optimize.js index 2343d47..f86f2bf 100644 --- a/js/optimize.js +++ b/js/optimize.js @@ -2,19 +2,28 @@ function optimizeStrDex() { if (!player_build) { return; } - const remaining = levelToSkillPoints(player_build.level) - player_build.assigned_skillpoints; - const base_skillpoints = player_build.base_skillpoints; + const skillpoints = skp_inputs.map(x => x.value); // JANK + let total_assigned = 0; + const min_assigned = player_build.base_skillpoints; + const base_totals = player_build.total_skillpoints; + let base_skillpoints = []; + for (let i in skp_order){ //big bren + const assigned = skillpoints[i] - base_totals[i] + min_assigned[i] + base_skillpoints.push(assigned); + total_assigned += assigned; + } + + const remaining = levelToSkillPoints(player_build.level) - total_assigned; const max_str_boost = 100 - base_skillpoints[0]; const max_dex_boost = 100 - base_skillpoints[1]; if (Math.min(remaining, max_str_boost, max_dex_boost) < 0) return; // Unwearable - const base_total_skillpoints = player_build.total_skillpoints; let str_bonus = remaining; let dex_bonus = 0; - let best_skillpoints = player_build.total_skillpoints; + let best_skillpoints = skillpoints; let best_damage = 0; for (let i = 0; i <= remaining; ++i) { - let total_skillpoints = base_total_skillpoints.slice(); + let total_skillpoints = skillpoints.slice(); total_skillpoints[0] += Math.min(max_str_boost, str_bonus); total_skillpoints[1] += Math.min(max_dex_boost, dex_bonus);