From c1d34bfed33a068b56dcf6be0e831c173c086de1 Mon Sep 17 00:00:00 2001 From: hppeng Date: Fri, 13 May 2022 23:01:03 -0700 Subject: [PATCH] Remove commented out code in sq2 builder files, add skeleton file for computation graph --- js/computation_graph.js | 27 +++++++++++++++++++++++++ js/sq2bs.js | 4 ---- js/sq2builder.js | 45 ++++++++++++++++------------------------- 3 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 js/computation_graph.js diff --git a/js/computation_graph.js b/js/computation_graph.js new file mode 100644 index 0000000..849e6e4 --- /dev/null +++ b/js/computation_graph.js @@ -0,0 +1,27 @@ + +class ComputeNode() { + constructor(name) { + this.inputs = []; + this.children = []; + this.value = 0; + this.compute_func = null; + this.callback_func = null; + this.name = name; + } + + update() { + let value_map = Map(); + for (const input of this.inputs) { + value_map.set(input.name, input.get_value()); + } + this.value = this.compute_func(this.value_map); + for (const child of this.children) { + child.update(); + } + this.callback_func(this.value); + } + + get_value() { + return this.value + } +} diff --git a/js/sq2bs.js b/js/sq2bs.js index 1bba067..8b96097 100644 --- a/js/sq2bs.js +++ b/js/sq2bs.js @@ -180,10 +180,6 @@ function update_field(field) { if (category == 'weapon') { document.querySelector("#weapon-img").setAttribute('src', '../media/items/new/generic-'+type+'.png'); } - - - - // call calc build } /* tabulars | man i hate this code but too lazy to fix /shrug */ diff --git a/js/sq2builder.js b/js/sq2builder.js index 47ec620..5300ce9 100644 --- a/js/sq2builder.js +++ b/js/sq2builder.js @@ -5,6 +5,20 @@ const url_tag = location.hash.slice(1); const BUILD_VERSION = "7.0.19"; +function setTitle() { + let text; + if (url_base.includes("hppeng-wynn")) { + text = "WynnBuilder UNSTABLE version "+BUILD_VERSION+" (db version "+DB_VERSION+")"; + } + else { + text = "WynnBuilder version "+BUILD_VERSION+" (db version "+DB_VERSION+")"; + document.getElementById("header").classList.add("funnynumber"); + } + document.getElementById("header").textContent = text; +} + +setTitle(); + let player_build; @@ -26,7 +40,7 @@ for (let i of skp_order) { let elem = document.getElementById(i+"-skp"); elem.addEventListener("change", (event) => { elem.classList.add("highlight"); - }); + }); editable_elems.push(elem); } @@ -292,18 +306,6 @@ function encodeBuild() { function calculateBuild(save_skp, skp){ try { - /* - let specialNames = ["Quake", "Chain_Lightning", "Curse", "Courage", "Wind_Prison"]; - for (const sName of specialNames) { - for (let i = 1; i < 6; i++) { - let elem = document.getElementById(sName + "-" + i); - let name = sName.replace("_", " "); - if (elem.classList.contains("toggleOn")) { //toggle the pressed button off - elem.classList.remove("toggleOn"); - } - } - } - */ if(player_build){ reset_powder_specials(); updateBoosts("skip", false); @@ -396,7 +398,6 @@ function calculateBuild(save_skp, skp){ } calculateBuildStats(); - // setTitle(); if (player_build.errored) throw new ListError(player_build.errors); @@ -489,7 +490,7 @@ function updateStats() { for (const s of skp) { manual_assigned += parseInt(s,10); } - } else { + } else { manual_assigned = parseInt(value,10); } let delta = manual_assigned - skillpoints[i]; @@ -502,12 +503,6 @@ function updateStats() { updatePowderSpecials("skip", false); updateBoosts("skip", false); } - /* - for (let id of editable_item_fields) { - player_build.statMap.set(id, parseInt(getValue(id))); - console.log(player_build.statMap.get(id)); - } - }*/ player_build.aggregateStats(); console.log(player_build.statMap); calculateBuildStats(); @@ -712,7 +707,6 @@ function calculateBuildStats() { let summarybox = document.getElementById("summary-box"); summarybox.textContent = ""; let skpRow = document.createElement("p"); - // let td = document.createElement("p"); let remainingSkp = document.createElement("p"); remainingSkp.classList.add("scaled-font"); @@ -732,11 +726,9 @@ function calculateBuildStats() { let skpWarning = document.createElement("span"); //skpWarning.classList.add("itemp"); skpWarning.classList.add("warning"); - // skpWarning.classList.add("skp-tooltip"); skpWarning.textContent = "WARNING: Too many skillpoints need to be assigned!"; let skpCount = document.createElement("p"); skpCount.classList.add("warning"); - // skpCount.classList.add("skp-tooltip"); skpCount.textContent = "For level " + (player_build.level>101 ? "101+" : player_build.level) + ", there are only " + levelToSkillPoints(player_build.level) + " skill points available."; summarybox.append(skpWarning); summarybox.append(skpCount); @@ -782,9 +774,6 @@ function calculateBuildStats() { } for (let i in player_build.items) { -// if (player_build.items[i].get("id") > 9999) { -// continue; -// } displaysq2ExpandedItem(player_build.items[i], buildFields[i]); collapse_element("#"+equipment_keys[i]+"-tooltip"); } @@ -1025,4 +1014,4 @@ function optimizeStrDex() { function init2() { load_ing_init(init); } -load_init(init2); \ No newline at end of file +load_init(init2);