Merge pull request #113 from hppeng-wynn/weapon-powder-optimization

Don't reload atree when build changes, only when player class changes
This commit is contained in:
hppeng-wynn 2022-07-11 21:57:39 -05:00 committed by GitHub
commit ab1d94ede1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 57 deletions

View file

@ -18,7 +18,7 @@
--> -->
<title>WynnBuilder</title> <title>WynnBuilder</title>
<link rel="icon" href="./media/memes/agony.png"> <link rel="icon" href="../media/icons/new/builder.png" type="image/icon type">
<meta name="viewport" content="width=device-width, initial-scale=.45, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=.45, user-scalable=no">
@ -51,6 +51,10 @@
<a href = "https://discord.gg/CGavnAnerv" target = "_blank"><img src = "../media/icons/discord.png" alt = "WB Discord" title = "WB Discord"><b>WB Discord</b></a> <a href = "https://discord.gg/CGavnAnerv" target = "_blank"><img src = "../media/icons/discord.png" alt = "WB Discord" title = "WB Discord"><b>WB Discord</b></a>
</div> </div>
<div class="container-fluid me-4" style="max-width: 95%; display: none"> <div class="container-fluid me-4" style="max-width: 95%; display: none">
<!-- REMOVE THIS DIV AT SOME POINT. -->
<div class = "row scaled-font mx-auto" id = "discord-banner-dev">
<div class = "col text-center item-title">Join the <a class = "link" href = "https://discord.gg/CGavnAnerv" target = "_blank">discord</a> today to suggest new features, submit bug reports, and hangout/talk to devs!</div>
</div>
<div class="row h-100 gx-lg-5 gy-3 mx-2 mx-lg-3 py-3"> <div class="row h-100 gx-lg-5 gy-3 mx-2 mx-lg-3 py-3">
<div class="col-xl-6"> <div class="col-xl-6">
<div class="row row-cols-1 mb-3 gy-4"> <div class="row row-cols-1 mb-3 gy-4">
@ -407,6 +411,8 @@
</div> </div>
<div class="col text-center"> <div class="col text-center">
<div id="summary-box"></div> <div id="summary-box"></div>
<div id="err-box"></div>
<div id="stack-box"></div>
<div id="str-warnings"></div> <div id="str-warnings"></div>
<div id="dex-warnings"></div> <div id="dex-warnings"></div>
<div id="int-warnings"></div> <div id="int-warnings"></div>
@ -428,7 +434,7 @@
</div> </div>
<div class = "col-3 py-2"> <div class = "col-3 py-2">
<button class = "col-auto button rounded scaled-font fw-bold text-light dark-5" id = "toggle-atree" onclick = "toggle_tab('atree-dropdown'); toggleButton('toggle-atree')"> <button class = "col-auto button rounded scaled-font fw-bold text-light dark-5" id = "toggle-atree" onclick = "toggle_tab('atree-dropdown'); toggleButton('toggle-atree')">
Show Ability Tree Edit Abilities
</button> </button>
</div> </div>
<div class = "col-3 py-2"> <div class = "col-3 py-2">
@ -617,10 +623,14 @@
</div> </div>
<div class = "col dark-6 rounded-bottom my-3 my-xl-1" id = "atree-dropdown" style = "display:none;"> <div class = "col dark-6 rounded-bottom my-3 my-xl-1" id = "atree-dropdown" style = "display:none;">
<div class="row row-cols-1 row-cols-xl-2"> <div class="row row-cols-1 row-cols-xl-2">
<div class="col border border-semi-light rounded dark-9 hide-scroll" id="atree-ui" style="height: 500px; overflow-y: auto;"> <div class="col border border-semi-light rounded dark-9 hide-scroll" id="atree-ui" style="height: 90vh; overflow-y: auto;">
</div> </div>
<div class="col mx-auto" id="atree-active"> <div class="col mx-auto" style="height: 90vh; overflow-y: auto;" id="atree-rhs">
<div class="col mx-auto" style="height: 2em; overflow-y: auto;" id="atree-header">
</div>
<div class="col mx-auto" style="overflow-y: auto;" id="atree-active">
</div>
</div> </div>
</div> </div>
</div> </div>
@ -1045,11 +1055,6 @@
<div class="col eDam"> <div class="col eDam">
Rage (Passive) Rage (Passive)
</div> </div>
<div class="col">
<input type = "range" class = "e_slider" id = "str_boost_armor" name = "str-boost-armor" autocomplete = "off" min = '0' max = '400' value = '0' step = '1' onchange = "update_armor_powder_specials('str_boost_armor')">
<input type="text" id="str_boost_armor_prev" autocomplete = "off" value="0" style = "display:none;">
<label id = "str_boost_armor_label" for="str-boost-armor">% Earth Dmg Boost: 0</label>
</div>
</div> </div>
</div> </div>
<div class="col" id="dex-boost" style="display: none;"> <div class="col" id="dex-boost" style="display: none;">
@ -1089,11 +1094,6 @@
<div class="col tDam"> <div class="col tDam">
Kill Streak (Passive) Kill Streak (Passive)
</div> </div>
<div class="col">
<input type = "range" class = "t_slider" id = "dex_boost_armor" name = "dex-boost-armor" autocomplete = "off" min = '0' max = '200' value = '0' step = '1' onchange = "update_armor_powder_specials('dex_boost_armor')">
<input type="text" id="dex_boost_armor_prev" autocomplete = "off" value="0" style = "display:none;">
<label id = "dex_boost_armor_label" for="dex-boost-armor">% Thunder Dmg Boost: 0</label>
</div>
</div> </div>
</div> </div>
<div class="col" id="int-boost"> <div class="col" id="int-boost">
@ -1133,11 +1133,6 @@
<div class="col wDam"> <div class="col wDam">
Concentration (Passive) Concentration (Passive)
</div> </div>
<div class="col">
<input type = "range" class = "w_slider" id = "int_boost_armor" name = "dex-boost-armor" autocomplete = "off" min = '0' max = '150' value = '0' step = '1' onchange = "update_armor_powder_specials('int_boost_armor')">
<input type="text" id="int_boost_armor_prev" autocomplete = "off" value="0" style = "display:none;">
<label id = "int_boost_armor_label" for="dex-boost-armor">% Water Dmg Boost: 0</label>
</div>
</div> </div>
</div> </div>
<div class="col" id="def-boost" style="display: none;"> <div class="col" id="def-boost" style="display: none;">
@ -1177,11 +1172,6 @@
<div class="col fDam"> <div class="col fDam">
Endurance (Passive) Endurance (Passive)
</div> </div>
<div class="col">
<input type = "range" class = "f_slider" id = "def_boost_armor" name = "def-boost-armor" autocomplete = "off" min = '0' max = '200' value = '0' step = '1' onchange = "update_armor_powder_specials('def_boost_armor')">
<input type="text" id="def_boost_armor_prev" autocomplete = "off" value="0" style = "display:none;">
<label id = "def_boost_armor_label" for="def-boost-armor">% Fire Dmg Boost: 0</label>
</div>
</div> </div>
</div> </div>
<div class="col" id="agi-boost" style="display: none;"> <div class="col" id="agi-boost" style="display: none;">
@ -1221,11 +1211,6 @@
<div class="col aDam"> <div class="col aDam">
Dodge (Passive) Dodge (Passive)
</div> </div>
<div class="col">
<input type = "range" class = "a_slider" id = "agi_boost_armor" name = "agi-boost-armor" autocomplete = "off" min = '0' max = '150' value = '0' step = '1' onchange = "update_armor_powder_specials('agi_boost_armor')">
<input type="text" id="agi_boost_armor_prev" autocomplete = "off" value="0" style = "display:none;">
<label id = "agi_boost_armor_label" for="agi-boost-armor">% Air Dmg Boost: 0</label>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -1263,21 +1248,10 @@
<div class = "col"> <div class = "col">
<div class = "col spell-display dark-5 rounded dark-shadow py-2 border border-dark" id="build-poison-stats">poison</div> <div class = "col spell-display dark-5 rounded dark-shadow py-2 border border-dark" id="build-poison-stats">poison</div>
</div> </div>
<div class = "col"> <div id="all-spells-display" class="row row-cols-1 gy-3 text-center scaled-font pe-0">
<div class = "col spell-display spell-expand dark-5 rounded dark-shadow pt-2 border border-dark" id="spell0-infoAvg">spell1</div> <div class = "col pe-0">
<div class = "col spell-display dark-5 rounded dark-shadow py-2" id = "spell0-info" style="display: none;">Spell 1</div> <div class = "col spell-display spell-expand dark-5 rounded dark-shadow pt-2 border border-dark" id="spell0-infoAvg">Input a weapon to see abilities!</div>
</div> </div>
<div class = "col">
<div class = "col spell-display spell-expand dark-5 rounded dark-shadow pt-2 border border-dark" id="spell1-infoAvg">spell2</div>
<div class = "col spell-display dark-5 rounded dark-shadow py-2" id = "spell1-info" style="display: none;">Spell 2</div>
</div>
<div class = "col">
<div class = "col spell-display spell-expand dark-5 rounded dark-shadow pt-2 border border-dark" id="spell2-infoAvg">spell3</div>
<div class = "col spell-display dark-5 rounded dark-shadow py-2" id = "spell2-info" style="display: none;">Spell 3</div>
</div>
<div class = "col">
<div class = "col spell-display spell-expand dark-5 rounded dark-shadow pt-2 border border-dark" id="spell3-infoAvg">spell4</div>
<div class = "col spell-display dark-5 rounded dark-shadow py-2" id = "spell3-info" style="display: none;">Spell 4</div>
</div> </div>
<div class = "col"> <div class = "col">
<div class = "spell-display dark-5 rounded dark-shadow py-2 border border-dark" id = "powder-special-stats"></div> <div class = "spell-display dark-5 rounded dark-shadow py-2 border border-dark" id = "powder-special-stats"></div>
@ -1329,7 +1303,7 @@
<div class="col-12 dark-5 scaled-font"> <div class="col-12 dark-5 scaled-font">
<footer class="text-center"> <footer class="text-center">
<div id="header2"> <div id="header2">
<p>Made by <b class = "hppeng">hppeng</b> and <b class = "ferricles">ferricles</b> with <a href = "../atlas" target = "_blank" class = "atlas link">Atlas Inc</a> (JavaScript required to function, nothing works without js)</p> <p>Made by <b class = "hppeng">hppeng</b>, <b class = "ferricles">ferricles</b>, and <b>reschan</b> with <a href = "../atlas" target = "_blank" class = "atlas link">Atlas Inc</a> (JavaScript required to function, nothing works without js)</p>
<p>Hard refresh the page (Ctrl+Shift+R on windows/chrome) if it isn't updating correctly.</p> <p>Hard refresh the page (Ctrl+Shift+R on windows/chrome) if it isn't updating correctly.</p>
</div> </div>
<div id="credits"> <div id="credits">
@ -1425,7 +1399,6 @@
<script type="text/javascript" src="../js/builder.js"></script> <script type="text/javascript" src="../js/builder.js"></script>
<script type="text/javascript" src="../js/builder_graph.js"></script> <script type="text/javascript" src="../js/builder_graph.js"></script>
<script type="text/javascript" src="../js/expr_parser.js"></script> <script type="text/javascript" src="../js/expr_parser.js"></script>
<script type="text/javascript" src="../js/items.js"></script>
<script type="text/javascript" src="../js/sq2items.js"></script> <script type="text/javascript" src="../js/sq2items.js"></script>
<script type="text/javascript" src="../js/optimize.js"></script> <script type="text/javascript" src="../js/optimize.js"></script>
@ -1435,5 +1408,6 @@
</div> </div>
<script src="https://d3js.org/d3.v7.js"></script> <script src="https://d3js.org/d3.v7.js"></script>
<script type="text/javascript" src="../js/render_compute_graph.js"></script> <script type="text/javascript" src="../js/render_compute_graph.js"></script>
</body> </body>
</html> </html>

View file

@ -97,35 +97,35 @@ const elem_mastery_abil = { display_name: "Elemental Mastery", id: 998, properti
// TODO: Range numbers // TODO: Range numbers
const default_abils = { const default_abils = {
wand: [{ Mage: [{
display_name: "Mage Melee", display_name: "Mage Melee",
id: 999, id: 999,
desc: "Mage basic attack.", desc: "Mage basic attack.",
properties: {range: 5000}, properties: {range: 5000},
effects: [default_spells.wand[0]] effects: [default_spells.wand[0]]
}, elem_mastery_abil ], }, elem_mastery_abil ],
spear: [{ Warrior: [{
display_name: "Warrior Melee", display_name: "Warrior Melee",
id: 999, id: 999,
desc: "Warrior basic attack.", desc: "Warrior basic attack.",
properties: {range: 2}, properties: {range: 2},
effects: [default_spells.spear[0]] effects: [default_spells.spear[0]]
}, elem_mastery_abil ], }, elem_mastery_abil ],
bow: [{ Archer: [{
display_name: "Archer Melee", display_name: "Archer Melee",
id: 999, id: 999,
desc: "Archer basic attack.", desc: "Archer basic attack.",
properties: {range: 20}, properties: {range: 20},
effects: [default_spells.bow[0]] effects: [default_spells.bow[0]]
}, elem_mastery_abil ], }, elem_mastery_abil ],
dagger: [{ Assassin: [{
display_name: "Assassin Melee", display_name: "Assassin Melee",
id: 999, id: 999,
desc: "Assassin basic attack.", desc: "Assassin basic attack.",
properties: {range: 2}, properties: {range: 2},
effects: [default_spells.dagger[0]] effects: [default_spells.dagger[0]]
}, elem_mastery_abil ], }, elem_mastery_abil ],
relik: [{ Shaman: [{
display_name: "Shaman Melee", display_name: "Shaman Melee",
id: 999, id: 999,
desc: "Shaman basic attack.", desc: "Shaman basic attack.",
@ -251,18 +251,18 @@ const atree_state_node = new (class extends ComputeNode {
* I stg if wynn makes abils that modify multiple spells * I stg if wynn makes abils that modify multiple spells
* ... well we can extend this by making `base_abil` a list instead but annoy * ... well we can extend this by making `base_abil` a list instead but annoy
* *
* Signature: AbilityTreeMergeNode(build: Build, atree: ATree, atree-state: RenderedATree) => Map[id, Ability] * Signature: AbilityTreeMergeNode(player-class: WeaponType, atree: ATree, atree-state: RenderedATree) => Map[id, Ability]
*/ */
const atree_merge = new (class extends ComputeNode { const atree_merge = new (class extends ComputeNode {
constructor() { super('builder-atree-merge'); } constructor() { super('builder-atree-merge'); }
compute_func(input_map) { compute_func(input_map) {
const build = input_map.get('build'); const player_class = input_map.get('player-class');
const atree_state = input_map.get('atree-state'); const atree_state = input_map.get('atree-state');
const atree_order = input_map.get('atree'); const atree_order = input_map.get('atree');
let abils_merged = new Map(); let abils_merged = new Map();
for (const abil of default_abils[build.weapon.statMap.get('type')]) { for (const abil of default_abils[player_class]) {
let tmp_abil = deepcopy(abil); let tmp_abil = deepcopy(abil);
if (!('desc' in tmp_abil)) { if (!('desc' in tmp_abil)) {
tmp_abil.desc = []; tmp_abil.desc = [];

View file

@ -4439,7 +4439,7 @@ const atrees = {
"display_name": "Wind Slash", "display_name": "Wind Slash",
"desc": "When using Teleport, slash through the air and deal damage to enemies you pierce.", "desc": "When using Teleport, slash through the air and deal damage to enemies you pierce.",
"archetype": "Riftwalker", "archetype": "Riftwalker",
"base_abil": "teleport", "base_abil": "Teleport",
"parents": ["Air Mastery", "Thunderstorm"], "parents": ["Air Mastery", "Thunderstorm"],
"dependencies": ["Teleport"], "dependencies": ["Teleport"],
"blockers": [], "blockers": [],

File diff suppressed because one or more lines are too long

View file

@ -1075,7 +1075,7 @@ function builder_graph_init() {
let class_node = new PlayerClassNode('builder-class').link_to(build_node); let class_node = new PlayerClassNode('builder-class').link_to(build_node);
// These two are defined in `atree.js` // These two are defined in `atree.js`
atree_node.link_to(class_node, 'player-class'); atree_node.link_to(class_node, 'player-class');
atree_merge.link_to(build_node, 'build'); atree_merge.link_to(class_node, 'player-class');
atree_graph_creator = new AbilityTreeEnsureNodesNode(build_node, stat_agg_node) atree_graph_creator = new AbilityTreeEnsureNodesNode(build_node, stat_agg_node)
.link_to(atree_collect_spells, 'spells'); .link_to(atree_collect_spells, 'spells');
atree_stats.link_to(build_node, 'build'); atree_stats.link_to(build_node, 'build');