Merge branch 'atree' into atree_hotfix

This commit is contained in:
hppeng 2022-07-21 22:03:58 -07:00
commit 4b0a336e3e
3 changed files with 24 additions and 5 deletions

View file

@ -1376,6 +1376,7 @@
<script type="text/javascript" src="../js/utils.js"></script> <script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/build_utils.js"></script> <script type="text/javascript" src="../js/build_utils.js"></script>
<script type="text/javascript" src="../js/computation_graph.js"></script> <script type="text/javascript" src="../js/computation_graph.js"></script>
<script type="text/javascript">COMPUTE_GRAPH_DEBUG=true;</script>
<!-- <script type="text/javascript" src="../js/icons.js"></script> --> <!-- <script type="text/javascript" src="../js/icons.js"></script> -->
<script type="text/javascript" src="../js/sq2icons.js"></script> <script type="text/javascript" src="../js/sq2icons.js"></script>
<script type="text/javascript" src="../js/powders.js"></script> <script type="text/javascript" src="../js/powders.js"></script>

View file

@ -403,6 +403,7 @@ const atree_validate = new (class extends ComputeNode {
reachable.add(ability.id); reachable.add(ability.id);
} }
if (atree_to_add.length == _add.length) { if (atree_to_add.length == _add.length) {
atree_to_add = _add;
break; break;
} }
atree_to_add = _add; atree_to_add = _add;
@ -1143,6 +1144,7 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) {
let apUsed = 0; let apUsed = 0;
let maxAP = parseInt(document.getElementById("active_AP_cap").innerHTML); let maxAP = parseInt(document.getElementById("active_AP_cap").innerHTML);
let archChosen = 0; let archChosen = 0;
let satisfiedDependencies = [];
let blockedBy = []; let blockedBy = [];
for (let [id, node_wrap] of atree_map.entries()) { for (let [id, node_wrap] of atree_map.entries()) {
if (!node_wrap.active || id == ability.id) { if (!node_wrap.active || id == ability.id) {
@ -1152,6 +1154,9 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) {
if (node_wrap.ability.archetype == ability.archetype) { if (node_wrap.ability.archetype == ability.archetype) {
archChosen++; archChosen++;
} }
if (ability.dependencies.includes(id)) {
satisfiedDependencies.push(id);
}
if (ability.blockers.includes(id)) { if (ability.blockers.includes(id)) {
blockedBy.push(node_wrap.ability.display_name); blockedBy.push(node_wrap.ability.display_name);
} }
@ -1182,6 +1187,18 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) {
container.appendChild(archReq); container.appendChild(archReq);
} }
// dependencies
for (let i = 0; i < ability.dependencies.length; i++) {
let dependency = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {});
if (satisfiedDependencies.includes(ability.dependencies[i])) {
dependency.innerHTML = reqYes;
} else {
dependency.innerHTML = reqNo;
}
dependency.innerHTML += " <span class = 'mc-gray'>Required Ability:</span> " + atree_map.get(ability.dependencies[i]).ability.display_name;
container.appendChild(dependency);
}
// blockers // blockers
for (let i = 0; i < blockedBy.length; i++) { for (let i = 0; i < blockedBy.length; i++) {
let blocker = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {}); let blocker = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {});

View file

@ -1,5 +1,6 @@
let all_nodes = []; let all_nodes = new Set();
let node_debug_stack = []; let node_debug_stack = [];
let COMPUTE_GRAPH_DEBUG = false;
class ComputeNode { class ComputeNode {
/** /**
* Make a generic compute node. * Make a generic compute node.
@ -21,7 +22,7 @@ class ComputeNode {
// 0: clean // 0: clean
this.inputs_dirty = new Map(); this.inputs_dirty = new Map();
this.inputs_dirty_count = 0; this.inputs_dirty_count = 0;
all_nodes.push(this); if (COMPUTE_GRAPH_DEBUG) { all_nodes.add(this); }
} }
/** /**
@ -34,7 +35,7 @@ class ComputeNode {
if (this.dirty === 0) { if (this.dirty === 0) {
return; return;
} }
node_debug_stack.push(this.name); if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.push(this.name); }
if (this.dirty == 2) { if (this.dirty == 2) {
let calc_inputs = new Map(); let calc_inputs = new Map();
for (const input of this.inputs) { for (const input of this.inputs) {
@ -46,7 +47,7 @@ class ComputeNode {
for (const child of this.children) { for (const child of this.children) {
child.mark_input_clean(this.name, this.value); child.mark_input_clean(this.name, this.value);
} }
node_debug_stack.pop(); if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.pop(); }
return this; return this;
} }
@ -190,7 +191,7 @@ function calcSchedule(node, timeout) {
} }
node.mark_dirty(); node.mark_dirty();
node.update_task = setTimeout(function() { node.update_task = setTimeout(function() {
node_debug_stack = []; if (COMPUTE_GRAPH_DEBUG) { node_debug_stack = []; }
node.update(); node.update();
node.update_task = null; node.update_task = null;
}, timeout); }, timeout);