Merge pull request #171 from hppeng-wynn/atree-NONE-update

Don't update the ability tree when NONE weapon is selected
This commit is contained in:
hppeng-wynn 2022-07-26 01:54:12 -07:00 committed by GitHub
commit c84fbc21b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View file

@ -199,7 +199,6 @@ const atree_node = new (class extends ComputeNode {
const atree_render = new (class extends ComputeNode {
constructor() {
super('builder-atree-render');
this.fail_cb = true;
this.UI_elem = document.getElementById("atree-ui");
this.list_elem = document.getElementById("atree-header");
}

View file

@ -429,6 +429,7 @@ class PlayerClassNode extends ValueCheckComputeNode {
compute_func(input_map) {
if (input_map.size !== 1) { throw "PlayerClassNode accepts exactly one input (build)"; }
const [build] = input_map.values(); // Extract values, pattern match it into size one list and bind to first element
if (build.weapon.statMap.has('NONE')) { return null; }
return wep_to_class.get(build.weapon.statMap.get('type'));
}
}

View file

@ -135,7 +135,7 @@ class ComputeNode {
}
class ValueCheckComputeNode extends ComputeNode {
constructor(name) { super(name); }
constructor(name) { super(name); this.valid_val = null; }
/**
* Request update of this compute node. Pushes updates to children,
@ -154,14 +154,11 @@ class ValueCheckComputeNode extends ComputeNode {
calc_inputs.set(this.input_translation.get(input.name), input.value);
}
let val = this.compute_func(calc_inputs);
if (val !== this.value) {
super.mark_dirty(2);
}
else {
console.log("soft update");
if (val !== null) {
if (val !== this.valid_val) { super.mark_dirty(2); } // don't mark dirty if NULL (no update)
this.valid_val = val;
}
this.value = val;
this.dirty = 0;
for (const child of this.children) {
child.mark_input_clean(this.name, this.value);