From 5f9c0d5185ea08b8dfa43b8513df5715f37b2073 Mon Sep 17 00:00:00 2001 From: hppeng Date: Thu, 23 Jun 2022 03:55:13 -0700 Subject: [PATCH] HOTFIX: str/dex optimizer working now --- js/builder_graph.js | 7 +++---- js/display.js | 1 - js/optimize.js | 30 +++++++++--------------------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/js/builder_graph.js b/js/builder_graph.js index f4d41ea..5cddf8d 100644 --- a/js/builder_graph.js +++ b/js/builder_graph.js @@ -223,9 +223,8 @@ class ItemInputNode extends InputNode { for (const [i, x] of zip2(equipment_inputs, replace_items)) { setValue(i, x); } - // NOTE: DO NOT REORDER FOR PERFORMANCE REASONS - for (const node of item_nodes) { node.mark_dirty(); } - for (const node of item_nodes) { node.update(); } + for (const node of item_nodes) { calcSchedule(node, 10); } + return this.compute_func(input_map); } return null; } @@ -942,6 +941,7 @@ let item_nodes = []; let powder_nodes = []; let spelldmg_nodes = []; let edit_input_nodes = []; +let skp_inputs = []; function builder_graph_init() { // Phase 1/2: Set up item input, propagate updates, etc. @@ -1022,7 +1022,6 @@ function builder_graph_init() { edit_id_output = new EditableIDSetterNode(edit_input_nodes); // Makes shallow copy of list. edit_id_output.link_to(build_node); - let skp_inputs = []; for (const skp of skp_order) { const elem = document.getElementById(skp+'-skp'); const node = new SumNumberInputNode('builder-'+skp+'-input', elem); diff --git a/js/display.js b/js/display.js index 11afa6a..8f7017d 100644 --- a/js/display.js +++ b/js/display.js @@ -51,7 +51,6 @@ function displaySetBonuses(parent_id,build) { } mock_item.set("powders", []); displayExpandedItem(mock_item, set_elem.id); - console.log(mock_item); } } diff --git a/js/optimize.js b/js/optimize.js index fdce392..2343d47 100644 --- a/js/optimize.js +++ b/js/optimize.js @@ -19,7 +19,7 @@ function optimizeStrDex() { total_skillpoints[1] += Math.min(max_dex_boost, dex_bonus); // Calculate total 3rd spell damage - let spell = spell_table[player_build.weapon.get("type")][2]; + let spell = spell_table[player_build.weapon.statMap.get("type")][2]; const stats = player_build.statMap; let critChance = skillPointsToPercentage(total_skillpoints[1]); let save_damages = []; @@ -41,8 +41,7 @@ function optimizeStrDex() { if (part.type === "damage") { let _results = calculateSpellDamage(stats, part.conversion, stats.get("sdRaw"), stats.get("sdPct"), - part.multiplier / 100, player_build.weapon, total_skillpoints, - player_build.damageMultiplier, player_build.externalStats); + part.multiplier / 100, player_build.weapon.statMap, total_skillpoints, 1); let totalDamNormal = _results[0]; let totalDamCrit = _results[1]; let results = _results[2]; @@ -75,27 +74,16 @@ function optimizeStrDex() { str_bonus -= 1; dex_bonus += 1; - } - // TODO: reduce duplicated code, @calculateBuild - let skillpoints = player_build.total_skillpoints; - let delta_total = 0; + console.log(best_skillpoints); + + // TODO do not merge for performance reasons for (let i in skp_order) { - let manual_assigned = best_skillpoints[i]; - let delta = manual_assigned - skillpoints[i]; - skillpoints[i] = manual_assigned; - player_build.base_skillpoints[i] += delta; - delta_total += delta; + skp_inputs[i].input_field.value = best_skillpoints[i]; + skp_inputs[i].mark_dirty(); } - player_build.assigned_skillpoints += delta_total; - - try { - calculateBuildStats(); - if (player_build.errored) - throw new ListError(player_build.errors); - } - catch (error) { - handleBuilderError(error); + for (let i in skp_order) { + skp_inputs[i].update(); } }