2022-07-10 03:35:06 +00:00
|
|
|
let itemCategories = [ "armor", "accessory", "weapon" ];
|
|
|
|
|
2022-05-12 23:41:45 +00:00
|
|
|
const sq2_translate_mappings = {
|
2021-10-17 15:53:48 +00:00
|
|
|
//"Name": "name",
|
|
|
|
//"Display Name": "displayName",
|
|
|
|
//"tier"Tier": ",
|
|
|
|
//"Set": "set",
|
|
|
|
"Powder Slots": "slots",
|
|
|
|
//"Type": "type",
|
|
|
|
//"armorType", (deleted)
|
|
|
|
//"color", (deleted)
|
|
|
|
//"lore", (deleted)
|
|
|
|
//"material", (deleted)
|
|
|
|
"Drop type": "drop",
|
|
|
|
"Quest requirement": "quest",
|
|
|
|
"Restriction": "restrict",
|
|
|
|
//"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",
|
|
|
|
"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",
|
|
|
|
//"Class Requirement": "classReq",
|
|
|
|
"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",
|
|
|
|
"Fixed IDs": "fixID",
|
|
|
|
"Custom Skin": "skin",
|
|
|
|
//"Item Category": "category",
|
|
|
|
|
|
|
|
"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",
|
|
|
|
|
|
|
|
"Rainbow Spell Damage": "rainbowRaw",
|
|
|
|
"Sprint": "sprint",
|
|
|
|
"Sprint Regen": "sprintReg",
|
|
|
|
"Jump Height": "jh",
|
|
|
|
"Loot Quality": "lq",
|
|
|
|
|
|
|
|
"Gather XP Bonus": "gXp",
|
|
|
|
"Gather Speed Bonus": "gSpd",
|
|
|
|
};
|
|
|
|
|
2022-05-12 23:41:45 +00:00
|
|
|
const sq2_special_mappings = {
|
2021-10-17 15:53:48 +00:00
|
|
|
"Sum (skill points)": new SumQuery(["str", "dex", "int", "def", "agi"]),
|
|
|
|
"Sum (Mana Sustain)": new SumQuery(["mr", "ms"]),
|
|
|
|
"Sum (Life Sustain)": new SumQuery(["hpr", "ls"]),
|
|
|
|
"Sum (Health + Health Bonus)": new SumQuery(["hp", "hpBonus"]),
|
|
|
|
"No Strength Req": new NegateQuery("strReq"),
|
|
|
|
"No Dexterity Req": new NegateQuery("dexReq"),
|
|
|
|
"No Intelligence Req": new NegateQuery("intReq"),
|
|
|
|
"No Agility Req": new NegateQuery("agiReq"),
|
|
|
|
"No Defense Req": new NegateQuery("defReq"),
|
|
|
|
};
|
|
|
|
|
2022-05-12 23:41:45 +00:00
|
|
|
let sq2ItemFilters = []
|
|
|
|
for (let x in sq2_translate_mappings) {
|
|
|
|
sq2ItemFilters.push(x);
|
2021-10-17 15:53:48 +00:00
|
|
|
}
|
2022-05-12 23:41:45 +00:00
|
|
|
for (let x in sq2_special_mappings) {
|
|
|
|
sq2ItemFilters.push(x);
|
2021-10-17 15:53:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function applyQuery(items, query) {
|
|
|
|
return items.filter(query.filter, query).sort(query.compare);
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayItems(items_copy) {
|
2021-10-29 08:08:36 +00:00
|
|
|
let items_parent = document.getElementById("search-results");
|
2021-10-17 15:53:48 +00:00
|
|
|
for (let i in items_copy) {
|
2021-10-29 08:08:36 +00:00
|
|
|
if (i > 200) {break;}
|
2021-10-17 15:53:48 +00:00
|
|
|
let item = items_copy[i];
|
|
|
|
let box = document.createElement("div");
|
2022-05-12 23:41:45 +00:00
|
|
|
box.classList.add("col-lg-3", "col-sm-6", "p-2");
|
2021-10-17 15:53:48 +00:00
|
|
|
box.id = "item"+i;
|
2021-10-29 08:08:36 +00:00
|
|
|
box.addEventListener("dblclick", function() {set_item(item);});
|
2022-05-12 23:41:45 +00:00
|
|
|
|
|
|
|
let bckgrdbox = document.createElement("div");
|
|
|
|
bckgrdbox.classList.add("dark-7", "rounded", "px-2", "col-auto");
|
|
|
|
box.appendChild(bckgrdbox);
|
|
|
|
bckgrdbox.id = "item"+i+"b";
|
2021-10-17 15:53:48 +00:00
|
|
|
items_parent.appendChild(box);
|
2022-07-10 03:04:28 +00:00
|
|
|
item.set("powders", []);
|
2022-07-10 03:35:06 +00:00
|
|
|
if (item.get("category") == "weapon") {
|
|
|
|
apply_weapon_powders(item);
|
|
|
|
}
|
2022-07-10 03:04:28 +00:00
|
|
|
displayExpandedItem(item, bckgrdbox.id, true);
|
2021-10-17 15:53:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let items_expanded;
|
|
|
|
|
|
|
|
function doItemSearch() {
|
|
|
|
// window.scrollTo(0, 0);
|
|
|
|
let queries = [];
|
2022-05-17 17:57:51 +00:00
|
|
|
queries.push(new NameQuery(document.getElementById("item-name-choice").value.trim()));
|
2021-10-17 15:53:48 +00:00
|
|
|
|
2022-05-17 17:57:51 +00:00
|
|
|
let categoryOrType = document.getElementById("item-category-choice").value;
|
2021-10-17 15:53:48 +00:00
|
|
|
if (itemTypes.includes(categoryOrType)) {
|
|
|
|
queries.push(new IdMatchQuery("type", categoryOrType));
|
|
|
|
}
|
|
|
|
else if (itemCategories.includes(categoryOrType)) {
|
|
|
|
queries.push(new IdMatchQuery("category", categoryOrType));
|
|
|
|
}
|
|
|
|
|
2022-05-17 17:57:51 +00:00
|
|
|
let rarity = document.getElementById("item-rarity-choice").value;
|
2021-10-17 15:53:48 +00:00
|
|
|
if (rarity) {
|
|
|
|
if (rarity === "ANY") {
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
queries.push(new IdMatchQuery("tier", rarity));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-17 17:57:51 +00:00
|
|
|
let level_dat = document.getElementById("item-level-choice").value ? document.getElementById("item-level-choice").value.split("-") : [1, 106];
|
2021-10-17 15:53:48 +00:00
|
|
|
queries.push(new LevelRangeQuery(parseInt(level_dat[0]), parseInt(level_dat[1])));
|
|
|
|
|
|
|
|
for (let i = 1; i <= 4; ++i) {
|
|
|
|
let raw_dat = document.getElementById("filter"+i+"-choice").value;
|
2022-07-10 03:35:06 +00:00
|
|
|
let filter_dat = sq2_translate_mappings[raw_dat];
|
2021-10-17 15:53:48 +00:00
|
|
|
if (filter_dat !== undefined) {
|
|
|
|
queries.push(new IdQuery(filter_dat));
|
|
|
|
continue;
|
|
|
|
}
|
2022-07-10 03:35:06 +00:00
|
|
|
filter_dat = sq2_special_mappings[raw_dat];
|
2021-10-17 15:53:48 +00:00
|
|
|
if (filter_dat !== undefined) {
|
|
|
|
queries.push(filter_dat);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let items_copy = items_expanded.slice();
|
2021-10-29 08:08:36 +00:00
|
|
|
document.getElementById("search-results").textContent = "";
|
2021-10-17 15:53:48 +00:00
|
|
|
for (const query of queries) {
|
|
|
|
console.log(items_copy.length);
|
2022-05-17 17:57:51 +00:00
|
|
|
console.log(query, query.filter);
|
2021-10-17 15:53:48 +00:00
|
|
|
items_copy = applyQuery(items_copy, query);
|
|
|
|
console.log(items_copy.length);
|
|
|
|
}
|
2022-05-12 23:41:45 +00:00
|
|
|
document.getElementById("summary").textContent = items_copy.length + " results:"
|
2021-10-17 15:53:48 +00:00
|
|
|
displayItems(items_copy);
|
|
|
|
}
|
|
|
|
|
2022-05-13 01:09:10 +00:00
|
|
|
function resetItemSearch() {
|
2022-05-17 17:57:51 +00:00
|
|
|
resetFields = ["item-name-choice", "item-category-choice", "item-rarity-choice", "item-level-choice", "filter1-choice", "filter2-choice", "filter3-choice", "filter4-choice"]
|
2022-05-13 01:09:10 +00:00
|
|
|
for (const field of resetFields) {
|
|
|
|
document.getElementById(field).value = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 15:53:48 +00:00
|
|
|
function init_items() {
|
2022-05-22 07:14:20 +00:00
|
|
|
items_expanded = items.filter( (i) => !("remapID" in i) ).map( (i) => expandItem(i) );
|
2022-07-10 04:02:17 +00:00
|
|
|
|
|
|
|
//init dropdowns
|
|
|
|
let filterInputs = new Map([["item-category", ["ALL", "armor", "helmet", "chestplate", "leggings", "boots", "accessory", "ring", "bracelet", "necklace", "weapon", "wand", "spear", "bow", "dagger", "relik"]],
|
|
|
|
["item-rarity", ["ANY", "Normal", "Unique", "Set", "Rare", "Legendary", "Fabled", "Mythic", "Sane"]],
|
|
|
|
["filter1", sq2ItemFilters],
|
|
|
|
["filter2", sq2ItemFilters],
|
|
|
|
["filter3", sq2ItemFilters],
|
|
|
|
["filter4", sq2ItemFilters]]);
|
|
|
|
for (const [field, data] of filterInputs) {
|
|
|
|
let field_choice = document.getElementById(field+"-choice");
|
|
|
|
// show dropdown on click
|
|
|
|
field_choice.onclick = function() {field_choice.dispatchEvent(new Event('input', {bubbles:true}));};
|
|
|
|
filterInputs.set(field, new autoComplete({
|
|
|
|
data: {
|
|
|
|
src: data,
|
|
|
|
},
|
|
|
|
threshold: 0,
|
|
|
|
selector: "#"+ field +"-choice",
|
|
|
|
wrapper: false,
|
|
|
|
resultsList: {
|
|
|
|
maxResults: 100,
|
|
|
|
tabSelect: true,
|
|
|
|
noResults: true,
|
|
|
|
class: "search-box dark-7 rounded-bottom px-2 fw-bold dark-shadow-sm",
|
|
|
|
element: (list, data) => {
|
|
|
|
let position = document.getElementById(field+'-choice').getBoundingClientRect();
|
|
|
|
list.style.top = position.bottom + window.scrollY +"px";
|
|
|
|
list.style.left = position.x+"px";
|
|
|
|
list.style.width = position.width+"px";
|
|
|
|
list.style.maxHeight = position.height * 4 +"px";
|
|
|
|
|
|
|
|
if (!data.results.length) {
|
|
|
|
message = document.createElement('li');
|
|
|
|
message.classList.add('scaled-font');
|
|
|
|
message.textContent = "No results found!";
|
|
|
|
list.prepend(message);
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
resultItem: {
|
|
|
|
class: "scaled-font search-item",
|
|
|
|
selected: "dark-5",
|
|
|
|
},
|
|
|
|
events: {
|
|
|
|
input: {
|
|
|
|
selection: (event) => {
|
|
|
|
if (event.detail.selection.value) {
|
|
|
|
event.target.value = event.detail.selection.value;
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
};
|
2021-10-17 15:53:48 +00:00
|
|
|
}
|
|
|
|
|
2022-07-10 03:04:28 +00:00
|
|
|
(async function() {
|
|
|
|
await Promise.resolve(load_init());
|
|
|
|
init_items();
|
|
|
|
})();
|