Change ingred and item Map
s to plain object access
This commit is contained in:
parent
6c7c274f81
commit
da6a422d79
11 changed files with 65 additions and 86 deletions
|
@ -1,7 +1,7 @@
|
||||||
let player_build;
|
let player_build;
|
||||||
let build_powders;
|
let build_powders;
|
||||||
|
|
||||||
function getItemNameFromID(id) { return idMap.get(id); }
|
function getItemNameFromID(id) { return idMap[id]; }
|
||||||
function getTomeNameFromID(id) { return tomeIDMap.get(id); }
|
function getTomeNameFromID(id) { return tomeIDMap.get(id); }
|
||||||
|
|
||||||
function parsePowdering(powder_info) {
|
function parsePowdering(powder_info) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ function init_autocomplete() {
|
||||||
if (eq == 'weapon') {
|
if (eq == 'weapon') {
|
||||||
for (const weaponType of weapon_keys) {
|
for (const weaponType of weapon_keys) {
|
||||||
for (const weapon of itemLists[weaponType]) {
|
for (const weapon of itemLists[weaponType]) {
|
||||||
let item_obj = itemMap.get(weapon);
|
let item_obj = itemMap[weapon];
|
||||||
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
|
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ function init_autocomplete() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const item of itemLists[eq.replace(/[0-9]/g, '')]) {
|
for (const item of itemLists[eq.replace(/[0-9]/g, '')]) {
|
||||||
let item_obj = itemMap.get(item);
|
let item_obj = itemMap[item];
|
||||||
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
|
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ function init_autocomplete() {
|
||||||
class: "scaled-font search-item",
|
class: "scaled-font search-item",
|
||||||
selected: "dark-5",
|
selected: "dark-5",
|
||||||
element: (item, data) => {
|
element: (item, data) => {
|
||||||
item.classList.add(itemMap.get(data.value).tier);
|
item.classList.add(itemMap[data.value].tier);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -154,7 +154,7 @@ class ItemInputNode extends InputNode {
|
||||||
let item;
|
let item;
|
||||||
if (item_text.slice(0, 3) == "CI-") { item = getCustomFromHash(item_text); }
|
if (item_text.slice(0, 3) == "CI-") { item = getCustomFromHash(item_text); }
|
||||||
else if (item_text.slice(0, 3) == "CR-") { item = getCraftFromHash(item_text); }
|
else if (item_text.slice(0, 3) == "CR-") { item = getCraftFromHash(item_text); }
|
||||||
else if (itemMap.has(item_text)) { item = new Item(itemMap.get(item_text)); }
|
else if (itemMap[item_text]) { item = new Item(itemMap[item_text]); }
|
||||||
else if (tomeMap.has(item_text)) { item = new Item(tomeMap.get(item_text)); }
|
else if (tomeMap.has(item_text)) { item = new Item(tomeMap.get(item_text)); }
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ function getCraftFromHash(hash) {
|
||||||
if (version === "1") {
|
if (version === "1") {
|
||||||
let ingreds = [];
|
let ingreds = [];
|
||||||
for (let i = 0; i < 6; i ++ ) {
|
for (let i = 0; i < 6; i ++ ) {
|
||||||
ingreds.push( expandIngredient(ingMap.get(ingIDMap.get(Base64.toInt(name.substring(2*i,2*i+2))))) );
|
ingreds.push( expandIngredient(ingMap[ingIDMap[Base64.toInt(name.substring(2*i,2*i+2))]]) );
|
||||||
}
|
}
|
||||||
let recipe = expandRecipe(recipeMap.get(recipeIDMap.get(Base64.toInt(name.substring(12,14)))));
|
let recipe = expandRecipe(recipeMap.get(recipeIDMap.get(Base64.toInt(name.substring(12,14)))));
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,6 @@ let player_craft;
|
||||||
|
|
||||||
function init_crafter() {
|
function init_crafter() {
|
||||||
//no ing
|
//no ing
|
||||||
|
|
||||||
console.log("all ingredients");
|
|
||||||
console.log(ingMap);
|
|
||||||
console.log("all recipes");
|
|
||||||
console.log(recipeMap);
|
|
||||||
/*console.log(ingList);
|
|
||||||
console.log(recipeList);
|
|
||||||
console.log(ingIDMap);
|
|
||||||
console.log(recipeIDMap);*/
|
|
||||||
try {
|
try {
|
||||||
document.getElementById("recipe-choice").addEventListener("change", (event) => {
|
document.getElementById("recipe-choice").addEventListener("change", (event) => {
|
||||||
updateMaterials();
|
updateMaterials();
|
||||||
|
@ -149,7 +140,7 @@ function calculateCraft() {
|
||||||
for (i = 1; i < 7; i++) {
|
for (i = 1; i < 7; i++) {
|
||||||
console.log("ing-choice-"+i);
|
console.log("ing-choice-"+i);
|
||||||
// console.log(getValue("ing-choice-"+i));
|
// console.log(getValue("ing-choice-"+i));
|
||||||
getValue("ing-choice-" + i) === "" ? ingreds.push(expandIngredient(ingMap.get("No Ingredient"))) : ingreds.push(expandIngredient(ingMap.get(getValue("ing-choice-" + i))));
|
getValue("ing-choice-" + i) === "" ? ingreds.push(expandIngredient(ingMap["No Ingredient"])) : ingreds.push(expandIngredient(ingMap[getValue("ing-choice-" + i)]));
|
||||||
}
|
}
|
||||||
let atkSpd = "NORMAL"; //default attack speed will be normal.
|
let atkSpd = "NORMAL"; //default attack speed will be normal.
|
||||||
for (const b of ["slow-atk-button", "normal-atk-button", "fast-atk-button"]) {
|
for (const b of ["slow-atk-button", "normal-atk-button", "fast-atk-button"]) {
|
||||||
|
@ -214,7 +205,7 @@ function decodeCraft(ing_url_tag) {
|
||||||
if (version === "1") {
|
if (version === "1") {
|
||||||
ingreds = [];
|
ingreds = [];
|
||||||
for (let i = 0; i < 6; i ++ ) {
|
for (let i = 0; i < 6; i ++ ) {
|
||||||
setValue("ing-choice-"+(i+1), ingIDMap.get(Base64.toInt(tag.substring(2*i,2*i+2))));
|
setValue("ing-choice-"+(i+1), ingIDMap[Base64.toInt(tag.substring(2*i,2*i+2))]);
|
||||||
//console.log(Base64.toInt(tag.substring(2*i,2*i+2)));
|
//console.log(Base64.toInt(tag.substring(2*i,2*i+2)));
|
||||||
}
|
}
|
||||||
recipe = recipeIDMap.get(Base64.toInt(tag.substring(12,14)));
|
recipe = recipeIDMap.get(Base64.toInt(tag.substring(12,14)));
|
||||||
|
|
|
@ -331,7 +331,7 @@ function populateFields() {
|
||||||
class_list.appendChild(el);
|
class_list.appendChild(el);
|
||||||
}
|
}
|
||||||
let item_list = document.getElementById("base-list");
|
let item_list = document.getElementById("base-list");
|
||||||
for (const name of itemMap.keys()) {
|
for (const name of Object.keys(itemMap)) {
|
||||||
let el = document.createElement("option");
|
let el = document.createElement("option");
|
||||||
el.value = name;
|
el.value = name;
|
||||||
item_list.appendChild(el);
|
item_list.appendChild(el);
|
||||||
|
@ -368,7 +368,7 @@ function useBaseItem(elem) {
|
||||||
let baseItem;
|
let baseItem;
|
||||||
|
|
||||||
//Check items db.
|
//Check items db.
|
||||||
for (const [name,itemObj] of itemMap) {
|
for (const [name,itemObj] of Object.entries(itemMap)) {
|
||||||
if (itemName === name) {
|
if (itemName === name) {
|
||||||
baseItem = expandItem(itemObj);
|
baseItem = expandItem(itemObj);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1885,17 +1885,17 @@ function displayIDProbabilities(parent_id, item, amp) {
|
||||||
if (amp != 0) {toggleButton("cork_amp_" + amp)}
|
if (amp != 0) {toggleButton("cork_amp_" + amp)}
|
||||||
|
|
||||||
let item_name = item.get("displayName");
|
let item_name = item.get("displayName");
|
||||||
console.log(itemMap.get(item_name))
|
console.log(itemMap[item_name])
|
||||||
|
|
||||||
let table_elem = document.createElement("table");
|
let table_elem = document.createElement("table");
|
||||||
parent_elem.appendChild(table_elem);
|
parent_elem.appendChild(table_elem);
|
||||||
for (const [id,val] of Object.entries(itemMap.get(item_name))) {
|
for (const [id,val] of Object.entries(itemMap[item_name])) {
|
||||||
if (rolledIDs.includes(id)) {
|
if (rolledIDs.includes(id)) {
|
||||||
let min = item.get("minRolls").get(id);
|
let min = item.get("minRolls").get(id);
|
||||||
let max = item.get("maxRolls").get(id);
|
let max = item.get("maxRolls").get(id);
|
||||||
//Apply corkian amps
|
//Apply corkian amps
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
let base = itemMap.get(item_name)[id];
|
let base = val;
|
||||||
if (reversedIDs.includes(id)) {max = Math.max( Math.round((0.3 + 0.05*amp) * base), 1)}
|
if (reversedIDs.includes(id)) {max = Math.max( Math.round((0.3 + 0.05*amp) * base), 1)}
|
||||||
else {min = Math.max( Math.round((0.3 + 0.05*amp) * base), 1)}
|
else {min = Math.max( Math.round((0.3 + 0.05*amp) * base), 1)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,8 @@ let amp_state = 0; //the level of corkian map used for ID purposes. Default 0.
|
||||||
function init_itempage() {
|
function init_itempage() {
|
||||||
//console.log(item_url_tag);
|
//console.log(item_url_tag);
|
||||||
|
|
||||||
//displayExpandedItem(expandItem(itemMap.get(item_url_tag).statMap, []), "item-view");
|
|
||||||
try{
|
try{
|
||||||
item = expandItem(itemMap.get(item_url_tag.replaceAll("%20"," ")), []);
|
item = expandItem(itemMap[item_url_tag.replaceAll("%20"," ")], []);
|
||||||
displaysq2ExpandedItem(item, "item-view");
|
displaysq2ExpandedItem(item, "item-view");
|
||||||
displaysq2AdditionalInfo("additional-info", item);
|
displaysq2AdditionalInfo("additional-info", item);
|
||||||
displaysq2IDCosts("identification-costs", item);
|
displaysq2IDCosts("identification-costs", item);
|
||||||
|
|
33
js/load.js
33
js/load.js
|
@ -7,8 +7,8 @@ let load_complete = false;
|
||||||
let load_in_progress = false;
|
let load_in_progress = false;
|
||||||
let items;
|
let items;
|
||||||
let sets = new Map();
|
let sets = new Map();
|
||||||
let itemMap;
|
let itemMap = {};
|
||||||
let idMap;
|
let idMap = {};
|
||||||
let redirectMap;
|
let redirectMap;
|
||||||
let itemLists = {};
|
let itemLists = {};
|
||||||
// List of 'raw' "none" items (No Helmet, etc), in order helmet, chestplate... ring1, ring2, brace, neck, weapon.
|
// List of 'raw' "none" items (No Helmet, etc), in order helmet, chestplate... ring1, ring2, brace, neck, weapon.
|
||||||
|
@ -232,26 +232,15 @@ for (let i = 0; i < none_items.length; i++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_maps() {
|
function init_maps() {
|
||||||
//warp
|
|
||||||
itemMap = new Map();
|
|
||||||
/* Mapping from item names to set names. */
|
|
||||||
idMap = new Map();
|
|
||||||
redirectMap = new Map();
|
|
||||||
items = items.concat(none_items);
|
|
||||||
//console.log(items);
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item.remapID === undefined) {
|
itemLists[item.type].push(item.displayName);
|
||||||
itemLists[item.type].push(item.displayName);
|
itemMap[item.displayName] = item;
|
||||||
itemMap.set(item.displayName, item);
|
idMap[item.id] = item.displayName;
|
||||||
if (none_items.includes(item)) {
|
|
||||||
idMap.set(item.id, "");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idMap.set(item.id, item.displayName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
redirectMap.set(item.id, item.remapID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (const item of none_items) {
|
||||||
|
itemLists[item.type].push(item.displayName);
|
||||||
|
itemMap[item.displayName] = item;
|
||||||
|
idMap[item.id] = "";
|
||||||
|
}
|
||||||
|
items = items.concat(none_items);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,13 @@ let iload_complete = false;
|
||||||
let ings;
|
let ings;
|
||||||
let recipes;
|
let recipes;
|
||||||
|
|
||||||
let ingMap;
|
let ingMap = {};
|
||||||
let ingList = [];
|
let ingList = [];
|
||||||
|
|
||||||
let recipeMap;
|
let recipeMap;
|
||||||
let recipeList = [];
|
let recipeList = [];
|
||||||
|
|
||||||
let ingIDMap;
|
let ingIDMap = {};
|
||||||
let recipeIDMap;
|
let recipeIDMap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -163,39 +163,41 @@ async function load_ing_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_ing_maps() {
|
function init_ing_maps() {
|
||||||
ingMap = new Map();
|
|
||||||
recipeMap = new Map();
|
recipeMap = new Map();
|
||||||
ingIDMap = new Map();
|
|
||||||
recipeIDMap = new Map();
|
recipeIDMap = new Map();
|
||||||
|
|
||||||
let ing = Object();
|
let ing = {
|
||||||
ing.name = "No Ingredient";
|
name: "No Ingredient",
|
||||||
ing.displayName = "No Ingredient";
|
displayName: "No Ingredient",
|
||||||
ing.tier = 0;
|
tier: 0,
|
||||||
ing.lvl = 0;
|
lvl: 0,
|
||||||
ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING", "COOKING", "ALCHEMISM", "SCRIBING"];
|
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING", "COOKING", "ALCHEMISM", "SCRIBING"],
|
||||||
ing.ids= {};
|
ids: {},
|
||||||
ing.itemIDs = {"dura": 0, "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
|
itemIDs: {"dura": 0, "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,},
|
||||||
ing.consumableIDs = {"dura": 0, "charges": 0};
|
consumableIDs: {"dura": 0, "charges": 0},
|
||||||
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
|
posMods: {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0},
|
||||||
ing.id = 4000;
|
id: 4000
|
||||||
ingMap.set(ing["displayName"], ing);
|
};
|
||||||
ingList.push(ing["displayName"]);
|
ingMap[ing.displayName] = ing;
|
||||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
ingList.push(ing.displayName);
|
||||||
|
ingIDMap[ing.id] = ing.displayName;
|
||||||
let numerals = new Map([[1, "I"], [2, "II"], [3, "III"], [4, "IV"], [5, "V"], [6, "VI"]]);
|
let numerals = new Map([[1, "I"], [2, "II"], [3, "III"], [4, "IV"], [5, "V"], [6, "VI"]]);
|
||||||
for (let i = 0; i < 5; i ++) {
|
for (let i = 0; i < 5; i ++) {
|
||||||
for (const powderIng of powderIngreds) {
|
for (const powderIng of powderIngreds) {
|
||||||
let ing = Object();
|
let ing = {
|
||||||
ing.name = "" + damageClasses[i+1] + " Powder " + numerals.get(powderIngreds.indexOf(powderIng) + 1);
|
name: "" + damageClasses[i+1] + " Powder " + numerals.get(powderIngreds.indexOf(powderIng) + 1),
|
||||||
ing.displayName = ing.name
|
tier: 0,
|
||||||
ing.tier = 0;
|
lvl: 0,
|
||||||
ing.lvl = 0;
|
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"],
|
||||||
ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"];
|
ids: {},
|
||||||
ing.ids = {};
|
isPowder: true,
|
||||||
ing.isPowder = true;
|
pid: 6*i + powderIngreds.indexOf(powderIng),
|
||||||
ing.pid = 6*i + powderIngreds.indexOf(powderIng);
|
itemIDs: {"dura": powderIng["durability"], "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0},
|
||||||
|
consumableIDs: {"dura": 0, "charges": 0},
|
||||||
|
posMods: {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0}
|
||||||
|
};
|
||||||
ing.id = 4001 + ing.pid;
|
ing.id = 4001 + ing.pid;
|
||||||
ing.itemIDs = {"dura": powderIng["durability"], "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
|
ing.diplayName = ing.name;
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 0:
|
case 0:
|
||||||
ing.itemIDs["strReq"] = powderIng["skpReq"];
|
ing.itemIDs["strReq"] = powderIng["skpReq"];
|
||||||
|
@ -213,23 +215,21 @@ function init_ing_maps() {
|
||||||
ing.itemIDs["agiReq"] = powderIng["skpReq"];
|
ing.itemIDs["agiReq"] = powderIng["skpReq"];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ing.consumableIDs = {"dura": 0, "charges": 0};
|
ingMap[ing.displayName] = ing;
|
||||||
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
|
ingList.push(ing.displayName);
|
||||||
ingMap.set(ing["displayName"],ing);
|
ingIDMap[ing.id] = ing.displayName;
|
||||||
ingList.push(ing["displayName"]);
|
|
||||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const ing of ings) {
|
for (const ing of ings) {
|
||||||
ingMap.set(ing["displayName"], ing);
|
ingMap[ing.displayName] = ing;
|
||||||
ingList.push(ing["displayName"]);
|
ingList.push(ing.displayName);
|
||||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
ingIDMap[ing.id] = ing.displayName;
|
||||||
}
|
}
|
||||||
for (const recipe of recipes) {
|
for (const recipe of recipes) {
|
||||||
recipeMap.set(recipe["name"], recipe);
|
recipeMap.set(recipe.name, recipe);
|
||||||
recipeList.push(recipe["name"]);
|
recipeList.push(recipe.name);
|
||||||
recipeIDMap.set(recipe["id"],recipe["name"]);
|
recipeIDMap.set(recipe.id, recipe.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ function calculate_skillpoints(equipment, weapon) {
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
const output_msg = `skillpoint calculation took ${(end-start)/ 1000} seconds.`;
|
const output_msg = `skillpoint calculation took ${(end-start)/ 1000} seconds.`;
|
||||||
console.log(output_msg);
|
console.log(output_msg);
|
||||||
document.getElementById('stack-box').textContent = output_msg;
|
document.getElementById('stack-box').textContent += output_msg;
|
||||||
return [equip_order, best_skillpoints, final_skillpoints, best_total, best_activeSetCounts];
|
return [equip_order, best_skillpoints, final_skillpoints, best_total, best_activeSetCounts];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue