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 build_powders;
|
||||
|
||||
function getItemNameFromID(id) { return idMap.get(id); }
|
||||
function getItemNameFromID(id) { return idMap[id]; }
|
||||
function getTomeNameFromID(id) { return tomeIDMap.get(id); }
|
||||
|
||||
function parsePowdering(powder_info) {
|
||||
|
|
|
@ -165,7 +165,7 @@ function init_autocomplete() {
|
|||
if (eq == 'weapon') {
|
||||
for (const weaponType of weapon_keys) {
|
||||
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") {
|
||||
continue;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ function init_autocomplete() {
|
|||
}
|
||||
} else {
|
||||
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") {
|
||||
continue;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ function init_autocomplete() {
|
|||
class: "scaled-font search-item",
|
||||
selected: "dark-5",
|
||||
element: (item, data) => {
|
||||
item.classList.add(itemMap.get(data.value).tier);
|
||||
item.classList.add(itemMap[data.value].tier);
|
||||
},
|
||||
},
|
||||
events: {
|
||||
|
|
|
@ -154,7 +154,7 @@ class ItemInputNode extends InputNode {
|
|||
let item;
|
||||
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 (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)); }
|
||||
|
||||
if (item) {
|
||||
|
|
|
@ -34,7 +34,7 @@ function getCraftFromHash(hash) {
|
|||
if (version === "1") {
|
||||
let ingreds = [];
|
||||
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)))));
|
||||
|
||||
|
|
|
@ -32,15 +32,6 @@ let player_craft;
|
|||
|
||||
function init_crafter() {
|
||||
//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 {
|
||||
document.getElementById("recipe-choice").addEventListener("change", (event) => {
|
||||
updateMaterials();
|
||||
|
@ -149,7 +140,7 @@ function calculateCraft() {
|
|||
for (i = 1; i < 7; i++) {
|
||||
console.log("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.
|
||||
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") {
|
||||
ingreds = [];
|
||||
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)));
|
||||
}
|
||||
recipe = recipeIDMap.get(Base64.toInt(tag.substring(12,14)));
|
||||
|
|
|
@ -331,7 +331,7 @@ function populateFields() {
|
|||
class_list.appendChild(el);
|
||||
}
|
||||
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");
|
||||
el.value = name;
|
||||
item_list.appendChild(el);
|
||||
|
@ -368,7 +368,7 @@ function useBaseItem(elem) {
|
|||
let baseItem;
|
||||
|
||||
//Check items db.
|
||||
for (const [name,itemObj] of itemMap) {
|
||||
for (const [name,itemObj] of Object.entries(itemMap)) {
|
||||
if (itemName === name) {
|
||||
baseItem = expandItem(itemObj);
|
||||
break;
|
||||
|
|
|
@ -1885,17 +1885,17 @@ function displayIDProbabilities(parent_id, item, amp) {
|
|||
if (amp != 0) {toggleButton("cork_amp_" + amp)}
|
||||
|
||||
let item_name = item.get("displayName");
|
||||
console.log(itemMap.get(item_name))
|
||||
console.log(itemMap[item_name])
|
||||
|
||||
let table_elem = document.createElement("table");
|
||||
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)) {
|
||||
let min = item.get("minRolls").get(id);
|
||||
let max = item.get("maxRolls").get(id);
|
||||
//Apply corkian amps
|
||||
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)}
|
||||
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() {
|
||||
//console.log(item_url_tag);
|
||||
|
||||
//displayExpandedItem(expandItem(itemMap.get(item_url_tag).statMap, []), "item-view");
|
||||
try{
|
||||
item = expandItem(itemMap.get(item_url_tag.replaceAll("%20"," ")), []);
|
||||
item = expandItem(itemMap[item_url_tag.replaceAll("%20"," ")], []);
|
||||
displaysq2ExpandedItem(item, "item-view");
|
||||
displaysq2AdditionalInfo("additional-info", 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 items;
|
||||
let sets = new Map();
|
||||
let itemMap;
|
||||
let idMap;
|
||||
let itemMap = {};
|
||||
let idMap = {};
|
||||
let redirectMap;
|
||||
let itemLists = {};
|
||||
// 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() {
|
||||
//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) {
|
||||
if (item.remapID === undefined) {
|
||||
itemLists[item.type].push(item.displayName);
|
||||
itemMap.set(item.displayName, item);
|
||||
if (none_items.includes(item)) {
|
||||
idMap.set(item.id, "");
|
||||
}
|
||||
else {
|
||||
idMap.set(item.id, item.displayName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
redirectMap.set(item.id, item.remapID);
|
||||
}
|
||||
itemLists[item.type].push(item.displayName);
|
||||
itemMap[item.displayName] = item;
|
||||
idMap[item.id] = item.displayName;
|
||||
}
|
||||
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 recipes;
|
||||
|
||||
let ingMap;
|
||||
let ingMap = {};
|
||||
let ingList = [];
|
||||
|
||||
let recipeMap;
|
||||
let recipeList = [];
|
||||
|
||||
let ingIDMap;
|
||||
let ingIDMap = {};
|
||||
let recipeIDMap;
|
||||
|
||||
/*
|
||||
|
@ -163,39 +163,41 @@ async function load_ing_init() {
|
|||
}
|
||||
|
||||
function init_ing_maps() {
|
||||
ingMap = new Map();
|
||||
recipeMap = new Map();
|
||||
ingIDMap = new Map();
|
||||
recipeIDMap = new Map();
|
||||
|
||||
let ing = Object();
|
||||
ing.name = "No Ingredient";
|
||||
ing.displayName = "No Ingredient";
|
||||
ing.tier = 0;
|
||||
ing.lvl = 0;
|
||||
ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING", "COOKING", "ALCHEMISM", "SCRIBING"];
|
||||
ing.ids= {};
|
||||
ing.itemIDs = {"dura": 0, "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
|
||||
ing.consumableIDs = {"dura": 0, "charges": 0};
|
||||
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
|
||||
ing.id = 4000;
|
||||
ingMap.set(ing["displayName"], ing);
|
||||
ingList.push(ing["displayName"]);
|
||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
||||
let ing = {
|
||||
name: "No Ingredient",
|
||||
displayName: "No Ingredient",
|
||||
tier: 0,
|
||||
lvl: 0,
|
||||
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING", "COOKING", "ALCHEMISM", "SCRIBING"],
|
||||
ids: {},
|
||||
itemIDs: {"dura": 0, "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},
|
||||
id: 4000
|
||||
};
|
||||
ingMap[ing.displayName] = ing;
|
||||
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"]]);
|
||||
for (let i = 0; i < 5; i ++) {
|
||||
for (const powderIng of powderIngreds) {
|
||||
let ing = Object();
|
||||
ing.name = "" + damageClasses[i+1] + " Powder " + numerals.get(powderIngreds.indexOf(powderIng) + 1);
|
||||
ing.displayName = ing.name
|
||||
ing.tier = 0;
|
||||
ing.lvl = 0;
|
||||
ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"];
|
||||
ing.ids = {};
|
||||
ing.isPowder = true;
|
||||
ing.pid = 6*i + powderIngreds.indexOf(powderIng);
|
||||
let ing = {
|
||||
name: "" + damageClasses[i+1] + " Powder " + numerals.get(powderIngreds.indexOf(powderIng) + 1),
|
||||
tier: 0,
|
||||
lvl: 0,
|
||||
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"],
|
||||
ids: {},
|
||||
isPowder: true,
|
||||
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.itemIDs = {"dura": powderIng["durability"], "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
|
||||
ing.diplayName = ing.name;
|
||||
switch(i) {
|
||||
case 0:
|
||||
ing.itemIDs["strReq"] = powderIng["skpReq"];
|
||||
|
@ -213,23 +215,21 @@ function init_ing_maps() {
|
|||
ing.itemIDs["agiReq"] = powderIng["skpReq"];
|
||||
break;
|
||||
}
|
||||
ing.consumableIDs = {"dura": 0, "charges": 0};
|
||||
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
|
||||
ingMap.set(ing["displayName"],ing);
|
||||
ingList.push(ing["displayName"]);
|
||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
||||
ingMap[ing.displayName] = ing;
|
||||
ingList.push(ing.displayName);
|
||||
ingIDMap[ing.id] = ing.displayName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const ing of ings) {
|
||||
ingMap.set(ing["displayName"], ing);
|
||||
ingList.push(ing["displayName"]);
|
||||
ingIDMap.set(ing["id"], ing["displayName"]);
|
||||
ingMap[ing.displayName] = ing;
|
||||
ingList.push(ing.displayName);
|
||||
ingIDMap[ing.id] = ing.displayName;
|
||||
}
|
||||
for (const recipe of recipes) {
|
||||
recipeMap.set(recipe["name"], recipe);
|
||||
recipeList.push(recipe["name"]);
|
||||
recipeIDMap.set(recipe["id"],recipe["name"]);
|
||||
recipeMap.set(recipe.name, recipe);
|
||||
recipeList.push(recipe.name);
|
||||
recipeIDMap.set(recipe.id, recipe.name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
const end = Date.now();
|
||||
const output_msg = `skillpoint calculation took ${(end-start)/ 1000} seconds.`;
|
||||
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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue