Merge branch 'dev' of https://github.com/hppeng-wynn/hppeng-wynn.github.io into dev
This commit is contained in:
commit
0d2498d934
7 changed files with 70 additions and 38 deletions
|
@ -1,9 +1,8 @@
|
|||
const url_base = location.href.split("#")[0];
|
||||
const url_tag = location.hash.slice(1);
|
||||
console.log(url_base);
|
||||
console.log(url_tag);
|
||||
|
||||
const BUILD_VERSION = "6.9.23";
|
||||
const BUILD_VERSION = "6.9.24";
|
||||
|
||||
function setTitle() {
|
||||
let text;
|
||||
|
|
2
craft.js
2
craft.js
|
@ -44,6 +44,7 @@ class Craft{
|
|||
this.atkSpd = attackSpeed;
|
||||
this.hash = hash;
|
||||
this.initCraftStats();
|
||||
this.statMap.set("hash", this.hash);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,6 +66,7 @@ class Craft{
|
|||
setHash(hash) {
|
||||
this.hash = hash;
|
||||
this.statMap.set("displayName", "CR-" + this.hash);
|
||||
this.statMap.set("hash", this.hash);
|
||||
}
|
||||
/* 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.
|
||||
|
|
14
display.js
14
display.js
|
@ -592,11 +592,16 @@ function displayExpandedItem(item, parent_id){
|
|||
if (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.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");
|
||||
img.src = "/media/items/generic-" + item.get("type") + ".png";
|
||||
img.alt = item.get("type");
|
||||
|
@ -607,7 +612,6 @@ function displayExpandedItem(item, parent_id){
|
|||
bckgrd.classList.add("itemp");
|
||||
active_elem.appendChild(bckgrd);
|
||||
bckgrd.appendChild(img);
|
||||
|
||||
} else if (skp_order.includes(id)) { //id = str, dex, int, def, or agi
|
||||
if ( item.get("tier") !== "Crafted" && active_elem.nodeName === "DIV") {
|
||||
p_elem.textContent = "";
|
||||
|
@ -748,7 +752,7 @@ function displayExpandedItem(item, parent_id){
|
|||
if(key === "Damage"){
|
||||
effect.textContent += elementIcons[skp_elements.indexOf(element)];
|
||||
}
|
||||
if (element === "w") {
|
||||
if (element === "w" && item.get("category") === "armor") {
|
||||
effect.textContent += " / Mana Used";
|
||||
}
|
||||
specialEffects.appendChild(effect);
|
||||
|
|
21
items.js
21
items.js
|
@ -130,10 +130,12 @@ function displayItems(items_copy) {
|
|||
box.classList.add("box");
|
||||
box.id = "item"+i;
|
||||
items_parent.appendChild(box);
|
||||
displayExpandedItem(expandItem(item, []), box.id);
|
||||
displayExpandedItem(item, box.id);
|
||||
}
|
||||
}
|
||||
|
||||
let items_expanded;
|
||||
|
||||
function doItemSearch() {
|
||||
window.scrollTo(0, 0);
|
||||
let queries = [];
|
||||
|
@ -174,26 +176,21 @@ function doItemSearch() {
|
|||
}
|
||||
}
|
||||
|
||||
let items_copy = items.slice();
|
||||
let items_copy = items_expanded.slice();
|
||||
document.getElementById("main").textContent = "";
|
||||
for (const query of queries) {
|
||||
console.log(items_copy.length);
|
||||
console.log(query);
|
||||
console.log(query.filter);
|
||||
items_copy = applyQuery(items_copy, query);
|
||||
console.log(items_copy.length);
|
||||
}
|
||||
document.getElementById("summary").textContent = items_copy.length + " results."
|
||||
displayItems(items_copy);
|
||||
}
|
||||
|
||||
function init() {
|
||||
return;
|
||||
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);
|
||||
items_expanded = items.filter( (i) => !("remapID" in i) ).map( (i) => expandItem(i, []) );
|
||||
}
|
||||
|
||||
load_init(init);
|
||||
|
|
2
load.js
2
load.js
|
@ -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
|
||||
|
||||
let db;
|
||||
|
|
57
query.js
57
query.js
|
@ -4,10 +4,7 @@ class NameQuery {
|
|||
constructor(string) { this.queryString = string.toLowerCase(); }
|
||||
|
||||
filter(item) {
|
||||
if (item.remapID === undefined) {
|
||||
return (item.displayName.toLowerCase().includes(this.queryString));
|
||||
}
|
||||
return false;
|
||||
return (item.get("displayName").toLowerCase().includes(this.queryString));
|
||||
}
|
||||
|
||||
compare(a, b) { return a < b; }
|
||||
|
@ -18,8 +15,8 @@ class LevelRangeQuery {
|
|||
constructor(min, max) { this.min = min; this.max = max; }
|
||||
|
||||
filter(item) {
|
||||
if (item.remapID === undefined) {
|
||||
return (item.lvl <= this.max && item.lvl >= this.min);
|
||||
if (item.get("remapID") === undefined) {
|
||||
return (item.get("lvl") <= this.max && item.get("lvl") >= this.min);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -34,7 +31,7 @@ class NegateQuery {
|
|||
}
|
||||
|
||||
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); } );
|
||||
|
@ -42,13 +39,33 @@ queryTypeMap.set("null", function(s) { return new IdQuery(s); } );
|
|||
class IdQuery {
|
||||
constructor(id) {
|
||||
this.id = id;
|
||||
if (nonRolledIDs.includes(id)) {
|
||||
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); } );
|
||||
|
@ -63,17 +80,27 @@ class IdMatchQuery {
|
|||
}
|
||||
|
||||
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 {
|
||||
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) {
|
||||
let balance = 0;
|
||||
for (const id of ids) {
|
||||
if (a[id]) { balance -= a[id]; }
|
||||
if (b[id]) { balance += b[id]; }
|
||||
for (const getter of getters) {
|
||||
if (getter(a)) { balance -= getter(a); }
|
||||
if (getter(b)) { balance += getter(b); }
|
||||
}
|
||||
return balance;
|
||||
};
|
||||
|
|
3
utils.js
3
utils.js
|
@ -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 skill = ["Strength", "Dexterity", "Intelligence", "Defense", "Agility"];
|
||||
let skp_elements = ["e","t","w","f","a"];
|
||||
|
|
Loading…
Reference in a new issue