diff --git a/js/build_utils.js b/js/build_utils.js index 927a265..48103ff 100644 --- a/js/build_utils.js +++ b/js/build_utils.js @@ -231,8 +231,15 @@ function expandItem(item) { } class Item { - constructor(item_obj) { - this.statMap = expandItem(item_obj); + constructor(item_obj = null) { + if (item_obj) { this.statMap = expandItem(item_obj); } + else { this.statMap = new Map(); } + } + + copy() { + const ret = new Item(); + ret.statMap = new Map(this.statMap); + return ret; } } diff --git a/js/builder_graph.js b/js/builder_graph.js index 5325574..22b0a60 100644 --- a/js/builder_graph.js +++ b/js/builder_graph.js @@ -203,8 +203,8 @@ class ItemPowderingNode extends ComputeNode { compute_func(input_map) { const powdering = input_map.get('powdering'); - const item = {}; - item.statMap = new Map(input_map.get('item').statMap); // TODO: performance + const input_item = input_map.get('item'); + const item = input_item.copy(); // TODO: performance const max_slots = item.statMap.get('slots'); item.statMap.set('powders', powdering.slice(0, max_slots)); @@ -1021,7 +1021,7 @@ function builder_graph_init() { let weapon_image = document.getElementById("weapon-img"); let weapon_dps = document.getElementById("weapon-dps"); new WeaponInputDisplayNode('weapon-type', weapon_image, weapon_dps).link_to(item_nodes[8]); - + // linking to atree verification atree_validate.link_to(level_input, 'level'); diff --git a/js/craft.js b/js/craft.js index db30aef..e6a15d2 100644 --- a/js/craft.js +++ b/js/craft.js @@ -397,4 +397,8 @@ class Craft{ statMap.set("crafted", true); this.statMap = statMap; } + + copy() { + return new Craft(this.recipe, this.mat_tiers, this.ingreds, this.atkSpd, this.hash.slice(3)); + } } diff --git a/js/custom.js b/js/custom.js index 4a6e94c..171a470 100644 --- a/js/custom.js +++ b/js/custom.js @@ -336,4 +336,7 @@ class Custom { this.statMap.set("restrict", "Custom Item") } + copy() { + return new Custom(new Map(this.statMap)); + } } diff --git a/js/load.js b/js/load.js index 2a504cd..8b4e713 100644 --- a/js/load.js +++ b/js/load.js @@ -254,5 +254,4 @@ function init_maps() { redirectMap.set(item.id, item.remapID); } } - console.log(itemMap); }