wynnbuilder-idk/js/items.js

176 lines
5.4 KiB
JavaScript
Raw Normal View History

2022-09-16 12:29:38 +00:00
// commented out filters
2021-01-26 09:17:11 +00:00
//"Name": "name",
//"Display Name": "displayName",
2022-08-19 00:15:17 +00:00
//"Tier": "tier",
2021-01-26 09:17:11 +00:00
//"Set": "set",
//"Type": "type",
//"Drop type": "drop", BROKEN
//"Quest requirement": "quest", BROKEN
//"Restriction": "restrict", BROKEN
2021-01-26 09:17:11 +00:00
//"Base Neutral Damage": "nDam",
//"Base Fire Damage": "fDam",
//"Base Water Damage": "wDam",
//"Base Air Damage": "aDam",
//"Base Thunder Damage": "tDam",
//"Base Earth Damage": "eDam",
//"Base Attack Speed": "atkSpd",
2022-09-16 12:29:38 +00:00
//"Class Requirement": "classReq",
// "Fixed IDs": "fixID", BROKEN
// "Custom Skin": "skin", BROKEN
//"Item Category": "category",
const translate_mappings = {
"Powder Slots": "slots",
2021-01-26 09:17:11 +00:00
"Health": "hp",
"Raw Fire Defense": "fDef",
"Raw Water Defense": "wDef",
"Raw Air Defense": "aDef",
"Raw Thunder Defense": "tDef",
"Raw Earth Defense": "eDef",
"Combat Level": "lvl",
"Req Strength": "strReq",
"Req Dexterity": "dexReq",
"Req Intelligence": "intReq",
"Req Agility": "agiReq",
"Req Defense": "defReq",
"% Health Regen": "hprPct",
"Mana Regen": "mr",
"% Spell Damage": "sdPct",
"% Melee Damage": "mdPct",
"Life Steal": "ls",
"Mana Steal": "ms",
"XP Bonus": "xpb",
"Loot Bonus": "lb",
"Reflection": "ref",
"Strength": "str",
"Dexterity": "dex",
"Intelligence": "int",
"Agility": "agi",
"Defense": "def",
"Thorns": "thorns",
"Exploding": "expd",
"Walk Speed": "spd",
"Attack Speed Bonus": "atkTier",
"Poison": "poison",
"Health Bonus": "hpBonus",
"Soul Point Regen": "spRegen",
"Stealing": "eSteal",
"Raw Health Regen": "hprRaw",
"Raw Spell": "sdRaw",
"Raw Melee": "mdRaw",
"% Fire Damage": "fDamPct",
"% Water Damage": "wDamPct",
"% Air Damage": "aDamPct",
"% Thunder Damage": "tDamPct",
"% Earth Damage": "eDamPct",
"% Fire Defense": "fDefPct",
"% Water Defense": "wDefPct",
"% Air Defense": "aDefPct",
"% Thunder Defense": "tDefPct",
"% Earth Defense": "eDefPct",
"1st Spell Cost %": "-spPct1",
"1st Spell Cost Raw": "-spRaw1",
"2nd Spell Cost %": "-spPct2",
"2nd Spell Cost Raw": "-spRaw2",
"3rd Spell Cost %": "-spPct3",
"3rd Spell Cost Raw": "-spRaw3",
"4th Spell Cost %": "-spPct4",
"4th Spell Cost Raw": "-spRaw4",
2022-09-17 14:15:39 +00:00
"Rainbow Spell Damage Raw": "rainbowRaw",
2021-01-26 09:17:11 +00:00
"Sprint": "sprint",
"Sprint Regen": "sprintReg",
"Jump Height": "jh",
"Loot Quality": "lq",
"Gather XP Bonus": "gXp",
2022-09-16 12:29:38 +00:00
"Gather Speed Bonus": "gSpd"
2021-01-26 09:17:11 +00:00
};
const special_mappings = {
2022-08-19 00:15:17 +00:00
"Sum (skill points)": "str+dex+int+def+agi",
"Sum (Mana Sustain)": "mr+ms",
"Sum (Life Sustain)": "hpr+ls",
2022-11-27 21:11:07 +00:00
"Sum (Health + Health Bonus)": "hp+hpBonus",
"Base DPS": "(nDam+fDam+wDam+aDam+tDam+eDam) * atkspdmod(atkspd)"
2021-01-26 09:17:11 +00:00
};
for (let x in translate_mappings) {
item_filters.push(x);
}
for (let x in special_mappings) {
item_filters.push(x);
2021-01-26 09:17:11 +00:00
}
types = {bow: false, spear: false, wand: false, dagger: false, relik: false, helmet: false, chestplate: false, leggings: false, boots: false, ring: false, bracelet: false, necklace: false};
search_tiers = {normal: true, unique: true, set: true, rare: true, legendary: true, fabled: true, mythic: true};
2021-01-26 09:17:11 +00:00
function display(items_copy) {
let items_parent = document.getElementById("search-results");
for (let i in items_copy) {
if (i > 200) {break;}
let item = items_copy[i].itemExp;
2022-08-03 08:00:39 +00:00
let box = make_elem('div', ['col-lg-3', 'col-sm-6', 'p-2'], {id: 'item'+i});
2022-08-03 08:00:39 +00:00
let bckgrdbox = make_elem("div", ["dark-7", "rounded", "px-2", "col-auto"], {id: 'item'+i+'b'});
box.append(bckgrdbox);
2021-01-24 03:58:53 +00:00
items_parent.appendChild(box);
item.set("powders", []);
if (item.get("category") == "weapon") {
apply_weapon_powders(item);
}
displayExpandedItem(item, bckgrdbox.id, true);
2021-01-24 03:58:53 +00:00
}
}
function filter_types_tiers(queries) {
// types
let allTypes = true, noTypes = true;
let typeQuery = "f:("
for (const type of Object.keys(types)) {
if (types[type]) {
typeQuery += "type=\"" + type + "\"|";
noTypes = false;
} else {
allTypes = false;
2021-01-26 09:17:11 +00:00
}
}
if (noTypes) {
document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 type selected";
return false;
} else if (!allTypes) {
queries.push(typeQuery.substring(0, typeQuery.length - 1) + ")");
}
2021-01-26 09:17:11 +00:00
// rarities
let allRarities = true, noRarities = true;
let rarityQuery = "f:("
for (const rarity of Object.keys(search_tiers)) {
if (search_tiers[rarity]) {
rarityQuery += "tiername=\"" + rarity + "\"|";
noRarities = false;
} else {
allRarities = false;
2021-01-26 09:17:11 +00:00
}
}
if (noRarities) {
document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 rarity selected";
return false;
} else if (!allRarities) {
queries.push(rarityQuery.substring(0, rarityQuery.length - 1) + ")");
}
return true;
2021-01-24 10:09:59 +00:00
}
function init_values() {
2022-08-03 07:54:40 +00:00
search_db = items.filter( i => ! i.remapID ).map( i => [i, expandItem(i, [])] );
expr_parser = new ExprParser(itemQueryProps, queryFuncs);
}
(async function() {
await Promise.resolve(load_init());
init_search();
})();