This commit is contained in:
ferricles 2021-02-05 10:17:50 -08:00
commit 0d2498d934
7 changed files with 70 additions and 38 deletions

View file

@ -1,9 +1,8 @@
const url_base = location.href.split("#")[0];
const url_tag = location.hash.slice(1); const url_tag = location.hash.slice(1);
console.log(url_base); console.log(url_base);
console.log(url_tag); console.log(url_tag);
const BUILD_VERSION = "6.9.23"; const BUILD_VERSION = "6.9.24";
function setTitle() { function setTitle() {
let text; let text;

View file

@ -44,6 +44,7 @@ class Craft{
this.atkSpd = attackSpeed; this.atkSpd = attackSpeed;
this.hash = hash; this.hash = hash;
this.initCraftStats(); this.initCraftStats();
this.statMap.set("hash", this.hash);
} }
@ -65,6 +66,7 @@ class Craft{
setHash(hash) { setHash(hash) {
this.hash = hash; this.hash = hash;
this.statMap.set("displayName", "CR-" + this.hash); this.statMap.set("displayName", "CR-" + this.hash);
this.statMap.set("hash", this.hash);
} }
/* Get all stats for this build. Stores in this.statMap. /* Get all stats for this build. Stores in this.statMap.
@pre The craft itself should be valid. No checking of validity of pieces is done here. @pre The craft itself should be valid. No checking of validity of pieces is done here.

View file

@ -592,11 +592,16 @@ function displayExpandedItem(item, parent_id){
if (item.get("tier") !== " ") { if (item.get("tier") !== " ") {
p_elem.classList.add(item.get("tier")); p_elem.classList.add(item.get("tier"));
} }
if(item.get("tier") === "Crafted") { if(item.get("crafted")) {
p_elem.remove();
p_elem = document.createElement("a");
p_elem.classList.add('itemp');
p_elem.classList.add("smalltitle"); p_elem.classList.add("smalltitle");
p_elem.classList.remove("title"); p_elem.classList.add(item.get("tier"));
p_elem.href = url_base + "crafter.html#" + item.get("hash");
p_elem.textContent = item.get(id);
active_elem.appendChild(p_elem);
} }
p_elem.append(document.createElement("br"));
let img = document.createElement("img"); let img = document.createElement("img");
img.src = "/media/items/generic-" + item.get("type") + ".png"; img.src = "/media/items/generic-" + item.get("type") + ".png";
img.alt = item.get("type"); img.alt = item.get("type");
@ -607,7 +612,6 @@ function displayExpandedItem(item, parent_id){
bckgrd.classList.add("itemp"); bckgrd.classList.add("itemp");
active_elem.appendChild(bckgrd); active_elem.appendChild(bckgrd);
bckgrd.appendChild(img); bckgrd.appendChild(img);
} else if (skp_order.includes(id)) { //id = str, dex, int, def, or agi } else if (skp_order.includes(id)) { //id = str, dex, int, def, or agi
if ( item.get("tier") !== "Crafted" && active_elem.nodeName === "DIV") { if ( item.get("tier") !== "Crafted" && active_elem.nodeName === "DIV") {
p_elem.textContent = ""; p_elem.textContent = "";
@ -748,7 +752,7 @@ function displayExpandedItem(item, parent_id){
if(key === "Damage"){ if(key === "Damage"){
effect.textContent += elementIcons[skp_elements.indexOf(element)]; effect.textContent += elementIcons[skp_elements.indexOf(element)];
} }
if (element === "w") { if (element === "w" && item.get("category") === "armor") {
effect.textContent += " / Mana Used"; effect.textContent += " / Mana Used";
} }
specialEffects.appendChild(effect); specialEffects.appendChild(effect);

View file

@ -130,10 +130,12 @@ function displayItems(items_copy) {
box.classList.add("box"); box.classList.add("box");
box.id = "item"+i; box.id = "item"+i;
items_parent.appendChild(box); items_parent.appendChild(box);
displayExpandedItem(expandItem(item, []), box.id); displayExpandedItem(item, box.id);
} }
} }
let items_expanded;
function doItemSearch() { function doItemSearch() {
window.scrollTo(0, 0); window.scrollTo(0, 0);
let queries = []; let queries = [];
@ -174,26 +176,21 @@ function doItemSearch() {
} }
} }
let items_copy = items.slice(); let items_copy = items_expanded.slice();
document.getElementById("main").textContent = ""; document.getElementById("main").textContent = "";
for (const query of queries) { for (const query of queries) {
console.log(items_copy.length);
console.log(query);
console.log(query.filter);
items_copy = applyQuery(items_copy, query); items_copy = applyQuery(items_copy, query);
console.log(items_copy.length);
} }
document.getElementById("summary").textContent = items_copy.length + " results." document.getElementById("summary").textContent = items_copy.length + " results."
displayItems(items_copy); displayItems(items_copy);
} }
function init() { function init() {
return; items_expanded = items.filter( (i) => !("remapID" in i) ).map( (i) => expandItem(i, []) );
let items_copy = items.slice();
//let query = new NameQuery("Bob's");
let query1 = new IdQuery("sdRaw");
items_copy = applyQuery(items_copy, query1);
let query2 = new TypeQuery("helmet");
items_copy = applyQuery(items_copy, query2);
displayItems(items_copy);
} }
load_init(init); load_init(init);

View file

@ -1,4 +1,4 @@
const DB_VERSION = 33; const DB_VERSION = 34;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js // @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
let db; let db;

View file

@ -4,10 +4,7 @@ class NameQuery {
constructor(string) { this.queryString = string.toLowerCase(); } constructor(string) { this.queryString = string.toLowerCase(); }
filter(item) { filter(item) {
if (item.remapID === undefined) { return (item.get("displayName").toLowerCase().includes(this.queryString));
return (item.displayName.toLowerCase().includes(this.queryString));
}
return false;
} }
compare(a, b) { return a < b; } compare(a, b) { return a < b; }
@ -18,8 +15,8 @@ class LevelRangeQuery {
constructor(min, max) { this.min = min; this.max = max; } constructor(min, max) { this.min = min; this.max = max; }
filter(item) { filter(item) {
if (item.remapID === undefined) { if (item.get("remapID") === undefined) {
return (item.lvl <= this.max && item.lvl >= this.min); return (item.get("lvl") <= this.max && item.get("lvl") >= this.min);
} }
return false; return false;
} }
@ -34,7 +31,7 @@ class NegateQuery {
} }
filter(item) { filter(item) {
return (!(this.id in item)) || (item[this.id] == 0); return (!item.get(this.id)) || (item.get(this.id) == 0);
} }
} }
queryTypeMap.set("null", function(s) { return new IdQuery(s); } ); queryTypeMap.set("null", function(s) { return new IdQuery(s); } );
@ -42,13 +39,33 @@ queryTypeMap.set("null", function(s) { return new IdQuery(s); } );
class IdQuery { class IdQuery {
constructor(id) { constructor(id) {
this.id = id; this.id = id;
if (nonRolledIDs.includes(id)) {
this.compare = function(a, b) { this.compare = function(a, b) {
return b[id] - a[id]; return b.get(id) - a.get(id);
}; };
this.filter = function(a) {
return a.get(this.id);
}
console.log("QUERY: ID, NONROLL");
}
else if (id in reversedIDs) {
this.compare = function(a, b) {
return b.get("maxRolls").get(id) - a.get("maxRolls").get(id);
};
this.filter = function(a) {
return a.get("maxRolls").get(this.id);
}
console.log("QUERY: ID, REVERSE");
}
else {
this.compare = function(a, b) {
return b.get("maxRolls").get(id) - a.get("maxRolls").get(id);
};
this.filter = function(a) {
return a.get("maxRolls").get(this.id);
}
console.log("QUERY: ID, ,,,");
} }
filter(item) {
return (this.id in item) && (item[this.id]);
} }
} }
queryTypeMap.set("stat", function(s) { return new IdQuery(s); } ); queryTypeMap.set("stat", function(s) { return new IdQuery(s); } );
@ -63,17 +80,27 @@ class IdMatchQuery {
} }
filter(item) { filter(item) {
return (this.id in item) && (item[this.id] == this.value); return item.get(this.id) && (item.get(this.id) == this.value);
} }
} }
class SumQuery { class SumQuery {
constructor(ids) { constructor(ids) {
let getters = [];
for (const id of ids) {
if (nonRolledIDs.includes(id)) {
getters.push(a => a.get(id));
}
else {
getters.push(a => a.get("maxRolls").get(id));
}
}
this.compare = function(a, b) { this.compare = function(a, b) {
let balance = 0; let balance = 0;
for (const id of ids) { for (const getter of getters) {
if (a[id]) { balance -= a[id]; } if (getter(a)) { balance -= getter(a); }
if (b[id]) { balance += b[id]; } if (getter(b)) { balance += getter(b); }
} }
return balance; return balance;
}; };

View file

@ -1,3 +1,6 @@
let getUrl = window.location;
const url_base = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
let skp_order = ["str","dex","int","def","agi"]; let skp_order = ["str","dex","int","def","agi"];
let skill = ["Strength", "Dexterity", "Intelligence", "Defense", "Agility"]; let skill = ["Strength", "Dexterity", "Intelligence", "Defense", "Agility"];
let skp_elements = ["e","t","w","f","a"]; let skp_elements = ["e","t","w","f","a"];