Fix crafted accessory durability display
also cleanup display.js
This commit is contained in:
parent
2b52264366
commit
8ecc3866c7
2 changed files with 42 additions and 58 deletions
|
@ -393,46 +393,45 @@ function displayExpandedItem(item, parent_id){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Show powder specials ;-;
|
//Show powder specials ;-;
|
||||||
let nonConsumables = ["relik", "wand", "bow", "spear", "dagger", "chestplate", "helmet", "leggings", "boots"];//, "ring", "bracelet", "necklace"];
|
let powder_specials_check = ["relik", "wand", "bow", "spear", "dagger", "chestplate", "helmet", "leggings", "boots"];
|
||||||
if(nonConsumables.includes(item.get("type"))) {
|
if(powder_specials_check.includes(item.get("type"))) {
|
||||||
let powder_special = document.createElement("div");
|
let powder_special = make_elem("div", ['col']);
|
||||||
powder_special.classList.add("col");
|
|
||||||
let powders = item.get("powders");
|
let powders = item.get("powders");
|
||||||
let element = "";
|
let element;
|
||||||
let power = 0;
|
let power_index;
|
||||||
for (let i = 0; i < powders.length; i++) {
|
for (let i = 0; i < powders.length; i++) {
|
||||||
let firstPowderType = skp_elements[Math.floor(powders[i]/6)];
|
const firstPowderType = skp_elements[Math.floor(powders[i]/6)];
|
||||||
if (element !== "") break;
|
const powder1_power = powders[i] % 6;
|
||||||
else if (powders[i]%6 > 2) { //t4+
|
if (powder1_power > 2) { //t4+
|
||||||
for (let j = i+1; j < powders.length; j++) {
|
for (let j = i+1; j < powders.length; j++) {
|
||||||
let currentPowderType = skp_elements[Math.floor(powders[j]/6)]
|
const currentPowderType = skp_elements[Math.floor(powders[j]/6)]
|
||||||
if (powders[j] % 6 > 2 && firstPowderType === currentPowderType) {
|
const powder2_power = powders[j] % 6;
|
||||||
|
if (powder2_power > 2 && firstPowderType === currentPowderType) {
|
||||||
element = currentPowderType;
|
element = currentPowderType;
|
||||||
power = Math.round(((powders[i] % 6 + powders[j] % 6 + 2) / 2 - 4) * 2);
|
power_index = powder1_power + powder2_power - 6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (element !== "") {//powder special is "[e,t,w,f,a]+[0,1,2,3,4]"
|
if (element) {//powder special is "[e,t,w,f,a]+[0,1,2,3,4]"
|
||||||
let powderSpecial = powderSpecialStats[ skp_elements.indexOf(element)];
|
const powderSpecial = powderSpecialStats[skp_elements.indexOf(element)];
|
||||||
let specialSuffixes = new Map([ ["Duration", " sec"], ["Radius", " blocks"], ["Chains", ""], ["Damage", "%"], ["Damage Boost", "%"], ["Knockback", " blocks"] ]);
|
const specialSuffixes = new Map([ ["Duration", " sec"], ["Radius", " blocks"], ["Chains", ""], ["Damage", "%"], ["Damage Boost", "%"], ["Knockback", " blocks"] ]);
|
||||||
let specialTitle = document.createElement("span");
|
const specialTitle = make_elem("span", [damageClasses[skp_elements.indexOf(element) + 1]]);
|
||||||
let specialEffects = document.createElement("span");
|
const specialEffects = document.createElement("span");
|
||||||
addClasses(specialTitle, [damageClasses[skp_elements.indexOf(element) + 1]]);
|
|
||||||
let effects;
|
let effects;
|
||||||
if (item.get("category") === "weapon") {//weapon
|
if (item.get("category") === "weapon") {//weapon
|
||||||
effects = powderSpecial["weaponSpecialEffects"];
|
effects = powderSpecial["weaponSpecialEffects"];
|
||||||
specialTitle.textContent = powderSpecial["weaponSpecialName"];
|
specialTitle.textContent = powderSpecial["weaponSpecialName"];
|
||||||
}else if (item.get("category") === "armor") {//armor
|
} else if (item.get("category") === "armor") {//armor
|
||||||
effects = powderSpecial["armorSpecialEffects"];
|
effects = powderSpecial["armorSpecialEffects"];
|
||||||
specialTitle.textContent += powderSpecial["armorSpecialName"] + ": ";
|
specialTitle.textContent += powderSpecial["armorSpecialName"] + ": ";
|
||||||
}
|
}
|
||||||
for (const [key,value] of effects.entries()) {
|
for (const [key,value] of effects.entries()) {
|
||||||
if (key !== "Description") {
|
if (key !== "Description") {
|
||||||
let effect = document.createElement("p");
|
let effect = make_elem("p", ["m-0"], {
|
||||||
effect.classList.add("m-0");
|
textContent: key + ": " + value[power_index] + specialSuffixes.get(key)
|
||||||
effect.textContent = key + ": " + value[power] + specialSuffixes.get(key);
|
});
|
||||||
if(key === "Damage"){
|
if(key === "Damage"){
|
||||||
effect.textContent += elementIcons[skp_elements.indexOf(element)];
|
effect.textContent += elementIcons[skp_elements.indexOf(element)];
|
||||||
}
|
}
|
||||||
|
@ -440,20 +439,19 @@ function displayExpandedItem(item, parent_id){
|
||||||
effect.textContent += " / Mana Used";
|
effect.textContent += " / Mana Used";
|
||||||
}
|
}
|
||||||
specialEffects.appendChild(effect);
|
specialEffects.appendChild(effect);
|
||||||
}else{
|
} else {
|
||||||
specialTitle.textContent += "[ " + effects.get("Description") + " ]";
|
specialTitle.textContent += "[ " + effects.get("Description") + " ]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
powder_special.appendChild(specialTitle);
|
powder_special.append(specialTitle, specialEffects);
|
||||||
powder_special.appendChild(specialEffects);
|
|
||||||
parent_div.appendChild(powder_special);
|
parent_div.appendChild(powder_special);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nonConsumables = ["relik", "wand", "bow", "spear", "dagger", "chestplate", "helmet", "leggings", "boots", "ring", "bracelet", "necklace"];
|
||||||
if(item.get("tier") && item.get("tier") === "Crafted") {
|
if(item.get("tier") && item.get("tier") === "Crafted") {
|
||||||
let dura_elem = document.createElement("div");
|
let dura_elem = make_elem("div", ["col"]);
|
||||||
dura_elem.classList.add("col");
|
let dura;
|
||||||
let dura = [];
|
|
||||||
let suffix = "";
|
let suffix = "";
|
||||||
if(nonConsumables.includes(item.get("type"))) {
|
if(nonConsumables.includes(item.get("type"))) {
|
||||||
dura = item.get("durability");
|
dura = item.get("durability");
|
||||||
|
@ -462,9 +460,9 @@ function displayExpandedItem(item, parent_id){
|
||||||
dura = item.get("duration");
|
dura = item.get("duration");
|
||||||
dura_elem.textContent = "Duration: "
|
dura_elem.textContent = "Duration: "
|
||||||
suffix = " sec."
|
suffix = " sec."
|
||||||
let charges = document.createElement("b");
|
parent_div.appendChild(make_elem('b', [], {
|
||||||
charges.textContent = "Charges: " + item.get("charges");
|
textContent: "Charges: " + item.get("charges")
|
||||||
parent_div.appendChild(charges);
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(dura) === "string") {
|
if (typeof(dura) === "string") {
|
||||||
|
@ -477,9 +475,7 @@ function displayExpandedItem(item, parent_id){
|
||||||
}
|
}
|
||||||
//Show item tier
|
//Show item tier
|
||||||
if (item.get("tier") && item.get("tier") !== " ") {
|
if (item.get("tier") && item.get("tier") !== " ") {
|
||||||
let item_desc_elem = document.createElement("div");
|
let item_desc_elem = make_elem("div", ["col", item.get("tier")]);
|
||||||
item_desc_elem.classList.add("col");
|
|
||||||
item_desc_elem.classList.add(item.get("tier"));
|
|
||||||
if (tome_types.includes(item.get("type"))) {
|
if (tome_types.includes(item.get("type"))) {
|
||||||
tome_type_map = new Map([["weaponTome", "Weapon Tome"],["armorTome", "Armor Tome"],["guildTome", "Guild Tome"]]);
|
tome_type_map = new Map([["weaponTome", "Weapon Tome"],["armorTome", "Armor Tome"],["guildTome", "Guild Tome"]]);
|
||||||
item_desc_elem.textContent = item.get("tier")+" "+tome_type_map.get(item.get("type"));
|
item_desc_elem.textContent = item.get("tier")+" "+tome_type_map.get(item.get("type"));
|
||||||
|
@ -491,20 +487,19 @@ function displayExpandedItem(item, parent_id){
|
||||||
|
|
||||||
//Show item hash if applicable
|
//Show item hash if applicable
|
||||||
if (item.get("crafted") || item.get("custom")) {
|
if (item.get("crafted") || item.get("custom")) {
|
||||||
let item_desc_elem = document.createElement("p");
|
parent_div.append(make_elem('p', ['itemp'], {
|
||||||
item_desc_elem.classList.add('itemp');
|
style: {
|
||||||
item_desc_elem.style.maxWidth = "100%";
|
maxWidth: '100%',
|
||||||
item_desc_elem.style.wordWrap = "break-word";
|
wordWrap: 'break-word',
|
||||||
item_desc_elem.style.wordBreak = "break-word";
|
wordBreak: 'break-word'
|
||||||
item_desc_elem.textContent = item.get("hash");
|
},
|
||||||
parent_div.append(item_desc_elem);
|
textContent: item.get('hash')
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.get("category") === "weapon") {
|
if (item.get("category") === "weapon") {
|
||||||
let total_damages = item.get("basedps");
|
let total_damages = item.get("basedps");
|
||||||
let base_dps_elem = document.createElement("p");
|
let base_dps_elem = make_elem("p", ["left", "itemp"]);
|
||||||
base_dps_elem.classList.add("left");
|
|
||||||
base_dps_elem.classList.add("itemp");
|
|
||||||
if (item.get("tier") === "Crafted") {
|
if (item.get("tier") === "Crafted") {
|
||||||
let base_dps_min = total_damages[0];
|
let base_dps_min = total_damages[0];
|
||||||
let base_dps_max = total_damages[1];
|
let base_dps_max = total_damages[1];
|
||||||
|
@ -514,8 +509,7 @@ function displayExpandedItem(item, parent_id){
|
||||||
else {
|
else {
|
||||||
base_dps_elem.textContent = "Base DPS: "+(total_damages);
|
base_dps_elem.textContent = "Base DPS: "+(total_damages);
|
||||||
}
|
}
|
||||||
parent_div.appendChild(document.createElement("p"));
|
parent_div.append(make_elem("p"), base_dps_elem);
|
||||||
parent_div.appendChild(base_dps_elem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1273,8 +1267,8 @@ function displayPowderSpecials(parent_elem, powderSpecials, stats, weapon, overa
|
||||||
//iterate through the special and display its effects.
|
//iterate through the special and display its effects.
|
||||||
let powder_special = make_elem("p", ["pt-3"]);
|
let powder_special = make_elem("p", ["pt-3"]);
|
||||||
let specialSuffixes = new Map([ ["Duration", " sec"], ["Radius", " blocks"], ["Chains", ""], ["Damage", "%"], ["Damage Boost", "%"], ["Knockback", " blocks"] ]);
|
let specialSuffixes = new Map([ ["Duration", " sec"], ["Radius", " blocks"], ["Chains", ""], ["Damage", "%"], ["Damage Boost", "%"], ["Knockback", " blocks"] ]);
|
||||||
let specialTitle = document.createElement("p");
|
let specialTitle = make_elem("p");
|
||||||
let specialEffects = document.createElement("p");
|
let specialEffects = make_elem("p");
|
||||||
specialTitle.classList.add(damageClasses[powderSpecialStats.indexOf(special[0]) + 1]);
|
specialTitle.classList.add(damageClasses[powderSpecialStats.indexOf(special[0]) + 1]);
|
||||||
let effects = special[0]["weaponSpecialEffects"];
|
let effects = special[0]["weaponSpecialEffects"];
|
||||||
let power = special[1];
|
let power = special[1];
|
||||||
|
|
10
js/utils.js
10
js/utils.js
|
@ -604,16 +604,6 @@ function matchType(object, target) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add multiple classes to a html element
|
|
||||||
*/
|
|
||||||
function addClasses(elem, classes) {
|
|
||||||
for (let _class of classes) {
|
|
||||||
elem.classList.add(_class);
|
|
||||||
}
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A utility function that reloads the page forcefully.
|
/** A utility function that reloads the page forcefully.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue