minor display.js refactor

This commit is contained in:
b 2021-09-25 11:57:57 -07:00
parent 9a0a040145
commit adf65431d5
13 changed files with 499 additions and 331 deletions

View file

@ -121,8 +121,8 @@ class Build{
} }
this.powders[0] = this.powders[0].slice(0,helmet.statMap.get("slots")); this.powders[0] = this.powders[0].slice(0,helmet.statMap.get("slots"));
helmet.statMap.set("powders",this.powders[0].slice()); helmet.statMap.set("powders",this.powders[0].slice());
helmet.applyPowders();
this.helmet = helmet.statMap; this.helmet = helmet.statMap;
applyArmorPowders(this.helmet, this.powders[0]);
if (this.helmet.get("custom")) { if (this.helmet.get("custom")) {
this.customItems.push(helmet); this.customItems.push(helmet);
} else if (this.helmet.get("crafted")) { //customs can also be crafted, but custom takes priority. } else if (this.helmet.get("crafted")) { //customs can also be crafted, but custom takes priority.
@ -148,8 +148,8 @@ class Build{
} }
this.powders[1] = this.powders[1].slice(0,chestplate.statMap.get("slots")); this.powders[1] = this.powders[1].slice(0,chestplate.statMap.get("slots"));
chestplate.statMap.set("powders",this.powders[1].slice()); chestplate.statMap.set("powders",this.powders[1].slice());
chestplate.applyPowders();
this.chestplate = chestplate.statMap; this.chestplate = chestplate.statMap;
applyArmorPowders(this.chesplate, this.powders[1]);
if (this.chestplate.get("custom")) { if (this.chestplate.get("custom")) {
this.customItems.push(chestplate); this.customItems.push(chestplate);
} else if (this.chestplate.get("crafted")) { //customs can also be crafted, but custom takes priority. } else if (this.chestplate.get("crafted")) { //customs can also be crafted, but custom takes priority.
@ -175,8 +175,8 @@ class Build{
} }
this.powders[2] = this.powders[2].slice(0,leggings.statMap.get("slots")); this.powders[2] = this.powders[2].slice(0,leggings.statMap.get("slots"));
leggings.statMap.set("powders",this.powders[2].slice()); leggings.statMap.set("powders",this.powders[2].slice());
leggings.applyPowders();
this.leggings = leggings.statMap; this.leggings = leggings.statMap;
applyArmorPowders(this.leggings, this.powders[2]);
if (this.leggings.get("custom")) { if (this.leggings.get("custom")) {
this.customItems.push(leggings); this.customItems.push(leggings);
} else if (this.leggings.get("crafted")) { //customs can also be crafted, but custom takes priority. } else if (this.leggings.get("crafted")) { //customs can also be crafted, but custom takes priority.
@ -201,9 +201,8 @@ class Build{
} }
this.powders[3] = this.powders[3].slice(0,boots.statMap.get("slots")); this.powders[3] = this.powders[3].slice(0,boots.statMap.get("slots"));
boots.statMap.set("powders",this.powders[3].slice()); boots.statMap.set("powders",this.powders[3].slice());
boots.applyPowders();
this.boots = boots.statMap; this.boots = boots.statMap;
console.log(boots); applyArmorPowders(this.boots, this.powders[3]);
if (this.boots.get("custom")) { if (this.boots.get("custom")) {
this.customItems.push(boots); this.customItems.push(boots);
} else if (this.boots.get("crafted")) { //customs can also be crafted, but custom takes priority. } else if (this.boots.get("crafted")) { //customs can also be crafted, but custom takes priority.

View file

@ -989,6 +989,7 @@
<script type="text/javascript" src="powders.js"></script> <script type="text/javascript" src="powders.js"></script>
<script type="text/javascript" src="skillpoints.js"></script> <script type="text/javascript" src="skillpoints.js"></script>
<script type="text/javascript" src="damage_calc.js"></script> <script type="text/javascript" src="damage_calc.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="load.js"></script> <script type="text/javascript" src="load.js"></script>
<script type="text/javascript" src="load_ing.js"></script> <script type="text/javascript" src="load_ing.js"></script>

View file

@ -75,9 +75,8 @@ class Craft{
this.statMap.set("hash", this.hash); this.statMap.set("hash", this.hash);
} }
applyPowders() { applyPowders() {
if (this.statMap.get("category") === "armor") { if (this.statMap.get("category") === "armor" || this.statMap.get("category" === "accessory")) {
//double apply armor powders //double apply armor powders
for(const id of this.statMap.get("powders")){ for(const id of this.statMap.get("powders")){
let powder = powderStats[id]; let powder = powderStats[id];
@ -88,8 +87,6 @@ class Craft{
}else if (this.statMap.get("category") === "weapon") { }else if (this.statMap.get("category") === "weapon") {
//do nothing - weapon powders are handled in displayExpandedItem //do nothing - weapon powders are handled in displayExpandedItem
} }
} }
setHash(hash) { setHash(hash) {
this.hash = "CR-" + hash; this.hash = "CR-" + hash;
@ -267,6 +264,12 @@ class Craft{
statMap.set(skp_elements[e]+"Dam",high1+"-"+high2); statMap.set(skp_elements[e]+"Dam",high1+"-"+high2);
} }
} else if (statMap.get("category") === "armor") { } else if (statMap.get("category") === "armor") {
low = Math.floor(low * matmult);
high = Math.floor(high * matmult);
statMap.set("hp",high);
statMap.set("hpLow",low);
}
if (statMap.get("category") === "armor" || statMap.get("category") == "accessory") {
for (let n in this.ingreds) { for (let n in this.ingreds) {
let ingred = this.ingreds[n]; let ingred = this.ingreds[n];
if (ingred.get("isPowder")) { if (ingred.get("isPowder")) {
@ -276,10 +279,6 @@ class Craft{
statMap.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (statMap.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]); statMap.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (statMap.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]);
} }
} }
low = Math.floor(low * matmult);
high = Math.floor(high * matmult);
statMap.set("hp",high);
statMap.set("hpLow",low);
} }
/* END SECTION */ /* END SECTION */

View file

@ -220,6 +220,7 @@
<script type="text/javascript" src="powders.js"></script> <script type="text/javascript" src="powders.js"></script>
<script type="text/javascript" src="skillpoints.js"></script> <script type="text/javascript" src="skillpoints.js"></script>
<script type="text/javascript" src="damage_calc.js"></script> <script type="text/javascript" src="damage_calc.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="load_ing.js"></script> <script type="text/javascript" src="load_ing.js"></script>
<script type="text/javascript" src="craft.js"></script> <script type="text/javascript" src="craft.js"></script>

View file

@ -182,7 +182,7 @@ function getCustomFromHash(hash) {
} }
/** An object representing a Custom Item. Mostly for vanity purposes. /** An object representing a Custom Item. Mostly for vanity purposes.
* @dep Requires the use of nonRolledIDs and rolledIDs from display.js. * @dep Requires the use of nonRolledIDs and rolledIDs from display_constants.js.
* @dep Requires the use of attackSpeeds from build.js. * @dep Requires the use of attackSpeeds from build.js.
*/ */
class Custom{ class Custom{
@ -198,22 +198,6 @@ class Custom{
this.initCustomStats(); this.initCustomStats();
} }
//Applies powders to the CI
applyPowders() {
if (this.statMap.get("category") === "armor") {
//double apply armor powders
for(const id of this.statMap.get("powders")){
let powder = powderStats[id];
let name = powderNames.get(id);
this.statMap.set(name.charAt(0) + "Def", (this.statMap.get(name.charAt(0)+"Def") || 0) + 2 * powder["defPlus"]);
this.statMap.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (this.statMap.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - 2 * powder["defMinus"]);
}
}else if (this.statMap.get("category") === "weapon") {
//do nothing - weapon powders are handled in displayExpandedItem
}
}
setHash(hash) { setHash(hash) {
let ihash = hash.slice(); let ihash = hash.slice();
if (ihash.slice(0,3) !== "CI-") { if (ihash.slice(0,3) !== "CI-") {

View file

@ -1885,6 +1885,7 @@
<script type="text/javascript" src="load_ing.js"></script> <script type="text/javascript" src="load_ing.js"></script>
<script type="text/javascript" src="crafter.js"></script> <script type="text/javascript" src="crafter.js"></script>
<script type="text/javascript" src="craft.js"></script> <script type="text/javascript" src="craft.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="custom.js"></script> <script type="text/javascript" src="custom.js"></script>
<script type="text/javascript" src="customizer.js"></script> <script type="text/javascript" src="customizer.js"></script>

View file

@ -1,21 +1,23 @@
let nonRolledIDs = ["name", "lore", "displayName", "tier", "set", "slots", "type", "material", "drop", "quest", "restrict", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "defReq", "agiReq","str", "dex", "int", "agi", "def", "fixID", "category", "id", "skillpoints", "reqs", "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_", "majorIds"]; /**
let rolledIDs = ["hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "thorns", "expd", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd"]; * Apply armor powdering.
let reversedIDs = [ "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ]; * Also for jeweling for crafted items.
let colorMap = new Map( */
[ function applyArmorPowders(expandedItem, powders) {
["Normal", "#fff"], applyArmorPowdersOnce(expandedItem, powders);
["Unique", "#ff5"], if (expandedItem.get("crafted")) {
["Rare","#f5f"], applyArmorPowdersOnce(expandedItem, powders);
["Legendary","#5ff"], }
["Fabled","#f55"], }
["Mythic","#a0a"], function applyArmorPowdersOnce(expandedItem, powders) {
["Crafted","#0aa"], for(const id of powders){
["Custom","#0aa"], let powder = powderStats[id];
["Set","#5f5"] let name = powderNames.get(id);
] expandedItem.set(name.charAt(0) + "Def", (expandedItem.get(name.charAt(0)+"Def") || 0) + powder["defPlus"]);
); expandedItem.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (expandedItem.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]);
}
}
function expandItem(item, powders){ function expandItem(item, powders) {
let minRolls = new Map(); let minRolls = new Map();
let maxRolls = new Map(); let maxRolls = new Map();
let expandedItem = new Map(); let expandedItem = new Map();
@ -61,12 +63,7 @@ function expandItem(item, powders){
expandedItem.set("maxRolls",maxRolls); expandedItem.set("maxRolls",maxRolls);
expandedItem.set("powders", powders); expandedItem.set("powders", powders);
if(item.category === "armor") { if(item.category === "armor") {
for(const id of powders){ applyArmorPowders(expandedItem, powders);
let powder = powderStats[id];
let name = powderNames.get(id);
expandedItem.set(name.charAt(0) + "Def", (expandedItem.get(name.charAt(0)+"Def") || 0) + powder["defPlus"]);
expandedItem.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (expandedItem.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]);
}
} }
return expandedItem; return expandedItem;
} }
@ -136,56 +133,6 @@ function idRound(id){
} }
} }
//Used for item IDs and ingredient id field IDs
let idPrefixes = {"displayName": "", "lvl":"Combat Level Min: ", "classReq":"Class Req: ","strReq":"Strength Min: ","dexReq":"Dexterity Min: ","intReq":"Intelligence Min: ","defReq":"Defense Min: ","agiReq":"Agility Min: ", "nDam_":"Neutral Damage: ", "eDam_":"Earth Damage: ", "tDam_":"Thunder Damage: ", "wDam_":"Water Damage: ", "fDam_":"Fire Damage: ", "aDam_":"Air Damage: ", "atkSpd":"Attack Speed: ", "hp":"Health : ", "eDef":"Earth Defense: ", "tDef":"Thunder Defense: ", "wDef":"Water Defense: ", "fDef":"Fire Defense: ", "aDef":"Air Defense: ", "str":"Strength: ", "dex":"Dexterity: ", "int":"Intelligence: ", "def":"Defense: ","agi":"Agility: ", "hpBonus":"Health Bonus: ", "hprRaw":"Health Regen Raw: ", "hprPct":"Health Regen %: ", "sdRaw":"Raw Spell Damage: ", "sdPct":"Spell Damage %: ", "mdRaw":"Raw Melee Damage: ", "mdPct":"Melee Damage %: ", "mr":"Mana Regen: ", "ms":"Mana Steal: ", "ref":"Reflection: ", "ls":"Life Steal: ", "poison":"Poison: ", "thorns":"Thorns: ", "expd":"Exploding: ", "spd":"Walk Speed Bonus: ", "atkTier":"Attack Speed Bonus: ", "eDamPct":"Earth Damage %: ", "tDamPct":"Thunder Damage %: ", "wDamPct":"Water Damage %: ", "fDamPct":"Fire Damage %: ", "aDamPct":"Air Damage %: ", "eDefPct":"Earth Defense %: ", "tDefPct":"Thunder Defense %: ", "wDefPct":"Water Defense %: ", "fDefPct":"Fire Defense %: ", "aDefPct":"Air Defense %: ", "spPct1":"1st Spell Cost %: ", "spRaw1":"1st Spell Cost Raw: ", "spPct2":"2nd Spell Cost %: ", "spRaw2":"2nd Spell Cost Raw: ", "spPct3":"3rd Spell Cost %: ", "spRaw3":"3rd Spell Cost Raw: ", "spPct4":"4th Spell Cost %: ", "spRaw4":"4th Spell Cost Raw: ", "rainbowRaw":"Rainbow Spell Damage Raw: ", "sprint":"Sprint Bonus: ", "sprintReg":"Sprint Regen Bonus: ", "jh":"Jump Height: ", "xpb":"Combat XP Bonus: ", "lb":"Loot Bonus: ", "lq":"Loot Quality: ", "spRegen":"Soul Point Regen: ", "eSteal":"Stealing: ", "gXp":"Gathering XP Bonus: ", "gSpd":"Gathering Speed Bonus: ", "slots":"Powder Slots: ", "set":"Set: ", "quest":"Quest Req: ", "restrict":"", "lore": ""};
let idSuffixes = {"displayName": "", "lvl":"", "classReq":"","strReq":"","dexReq":"","intReq":"","defReq":"","agiReq":"", "nDam_":"", "eDam_":"", "tDam_":"", "wDam_":"", "fDam_":"", "aDam_":"", "atkSpd":"", "hp":"", "eDef":"", "tDef":"", "wDef":"", "fDef":"", "aDef":"", "str":"", "dex":"", "int":"", "def":"","agi":"", "hpBonus":"", "hprRaw":"", "hprPct":"%", "sdRaw":"", "sdPct":"%", "mdRaw":"", "mdPct":"%", "mr":"/5s", "ms":"/3s", "ref":"%", "ls":"/3s", "poison":"/3s", "thorns":"%", "expd":"%", "spd":"%", "atkTier":" tier", "eDamPct":"%", "tDamPct":"%", "wDamPct":"%", "fDamPct":"%", "aDamPct":"%", "eDefPct":"%", "tDefPct":"%", "wDefPct":"%", "fDefPct":"%", "aDefPct":"%", "spPct1":"%", "spRaw1":"", "spPct2":"%", "spRaw2":"", "spPct3":"%", "spRaw3":"", "spPct4":"%", "spRaw4":"", "rainbowRaw":"", "sprint":"%", "sprintReg":"%", "jh":"", "xpb":"%", "lb":"%", "lq":"%", "spRegen":"%", "eSteal":"%", "gXp":"%", "gSpd":"%", "slots":"", "set":" set.", "quest":"", "restrict":"", "lore": ""};
//Used for ingredient IDs - name, lvl, tier. As of now, not used.
/*let ingPrefixes = {"name": "", "lvl": "", "tier": ""};
let ingSuffixes = {"name": "", "lvl": "", "tier": ""}*/
//Used for ingredient consumableIDs
let consumableIDPrefixes = {
"charges": "Charges: ",
"dura": "Duration: "
}
let consumableIDSuffixes = {
"charges": "",
"dura": " sec."
}
//Used for ingredient itemIDs
let itemIDPrefixes = {
"dura": "Durability: ",
"strReq": "Strength Min: ",
"dexReq": "Dexterity Min: ",
"intReq": "Intelligence Min: ",
"defReq": "Defense Min: ",
"agiReq": "Agility Min: "
}
/*let itemIDSuffixes = {
"dura": "",
"strReq": "",
"dexReq": "",
"intReq": "",
"defReq": "",
"agiReq": ""
}*/
//Used for ingredient posMods IDs
let posModPrefixes = {
"left":"Effectiveness Left: ",
"right":"EFfectiveness Right: ",
"above":"Effectiveness Above: ",
"under":"Effectiveness Under: ",
"touching":"EFfectiveness Touching: ",
"notTouching":"Effectiveness Not Touching: "
}
let posModSuffixes = {
"left":"%",
"right":"%",
"above":"%",
"under":"%",
"touching":"%",
"notTouching":"%"
}
function apply_elemental_format(p_elem, id, suffix) { function apply_elemental_format(p_elem, id, suffix) {
suffix = (typeof suffix !== 'undefined') ? suffix : ""; suffix = (typeof suffix !== 'undefined') ? suffix : "";
// THIS IS SO JANK BUT IM TOO LAZY TO FIX IT TODO // THIS IS SO JANK BUT IM TOO LAZY TO FIX IT TODO
@ -255,40 +202,7 @@ function displayBuildStats(parent_id,build){
// !elemental is some janky hack for elemental damage. // !elemental is some janky hack for elemental damage.
// normals just display a thing. // normals just display a thing.
let display_commands = [ let display_commands = build_overall_display_commands;
// "#ldiv",
// "!elemental",
// "hp",
// "fDef", "wDef", "aDef", "tDef", "eDef",
// "!elemental",
// "#table",
// "hprRaw", "hprPct",
"#table",
"str", "dex", "int", "def", "agi",
"mr", "ms",
"hprRaw", "hprPct",
"sdRaw", "sdPct",
"mdRaw", "mdPct",
"ref", "thorns",
"ls",
"poison",
"expd",
"spd",
"atkTier",
"!elemental",
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
// "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw",
"sprint", "sprintReg",
"jh",
"xpb", "lb", "lq",
"spRegen",
"eSteal",
"gXp", "gSpd",
];
// Clear the parent div. // Clear the parent div.
setHTML(parent_id, ""); setHTML(parent_id, "");
@ -368,11 +282,10 @@ function displayBuildStats(parent_id,build){
style === "positive" ? style = "negative" : style = "positive"; style === "positive" ? style = "negative" : style = "positive";
} }
if (id === "poison" && id_val > 0) { if (id === "poison" && id_val > 0) {
id_val = Math.ceil(id_val*(build.statMap.get("poisonPct") + build.externalStats.get("poisonPct"))/100); id_val = Math.ceil(id_val*build.statMap.get("poisonPct")/100);
} }
displayFixedID(active_elem, id, id_val, elemental_format, style); displayFixedID(active_elem, id, id_val, elemental_format, style);
if (id === "poison" && id_val > 0) { if (id === "poison" && id_val > 0) {
let style = "positive";
let row = document.createElement('tr'); let row = document.createElement('tr');
let value_elem = document.createElement('td'); let value_elem = document.createElement('td');
value_elem.classList.add('right'); value_elem.classList.add('right');
@ -388,12 +301,6 @@ function displayBuildStats(parent_id,build){
active_elem.appendChild(row); active_elem.appendChild(row);
} else if (id === "ls" && id_val != 0) { } else if (id === "ls" && id_val != 0) {
let style;
if (id_val > 0) {
style = "positive";
} else{
style = "negative";
}
let row = document.createElement("tr"); let row = document.createElement("tr");
let title = document.createElement("td"); let title = document.createElement("td");
title.classList.add("left"); title.classList.add("left");
@ -475,57 +382,7 @@ function displayExpandedItem(item, parent_id){
} else if (item.get("category") === "armor") { } else if (item.get("category") === "armor") {
} }
let display_commands = [ let display_commands = item_display_commands;
"#cdiv",
"displayName",
//"type", //REPLACE THIS WITH SKIN
"#ldiv",
"atkSpd",
"#ldiv",
"!elemental",
"hp",
"nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_",
"fDef", "wDef", "aDef", "tDef", "eDef",
"!elemental",
"#ldiv",
"classReq",
"lvl",
"strReq", "dexReq", "intReq", "defReq","agiReq",
"#ldiv",
"str", "dex", "int", "def", "agi",
"#table",
"str", "dex", "int", "def", "agi", //jank lmao
"hpBonus",
"hprRaw", "hprPct",
"sdRaw", "sdPct",
"mdRaw", "mdPct",
"mr", "ms",
"ref", "thorns",
"ls",
"poison",
"expd",
"spd",
"atkTier",
"!elemental",
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
"fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw",
"sprint", "sprintReg",
"jh",
"xpb", "lb", "lq",
"spRegen",
"eSteal",
"gXp", "gSpd",
"#ldiv",
"majorIds",
"slots",
"set",
"lore",
"quest",
"restrict"
];
// Clear the parent div. // Clear the parent div.
setHTML(parent_id, ""); setHTML(parent_id, "");
@ -629,21 +486,8 @@ function displayExpandedItem(item, parent_id){
p_elem.classList.add("itemp"); p_elem.classList.add("itemp");
p_elem.textContent = "Combat Level Min: " + item.get("lvlLow") + "-" + item.get(id); p_elem.textContent = "Combat Level Min: " + item.get("lvlLow") + "-" + item.get(id);
active_elem.appendChild(p_elem); active_elem.appendChild(p_elem);
} else { } else if (id === "displayName") {
let p_elem; let p_elem = document.createElement("a");
if ( !(item.get("tier") === "Crafted" && item.get("category") === "armor" && id === "hp") && (!skp_order.includes(id)) || (skp_order.includes(id) && item.get("tier") !== "Crafted" && active_elem.nodeName === "DIV") ) { //skp warp
p_elem = displayFixedID(active_elem, id, item.get(id), elemental_format);
} else if (item.get("tier") === "Crafted" && item.get("category") === "armor" && id === "hp") {
p_elem = displayFixedID(active_elem, id, item.get(id+"Low")+"-"+item.get(id), elemental_format);
}
if (id === "displayName") {
p_elem.classList.add("title");
if (item.get("tier") !== " ") {
p_elem.classList.add(item.get("tier"));
}
p_elem.remove();
p_elem = document.createElement("a");
p_elem.classList.add('itemp'); p_elem.classList.add('itemp');
p_elem.classList.add("smalltitle"); p_elem.classList.add("smalltitle");
p_elem.classList.add(item.has("tier") ? item.get("tier").replace(" ","") : "none"); p_elem.classList.add(item.has("tier") ? item.get("tier").replace(" ","") : "none");
@ -659,7 +503,6 @@ function displayExpandedItem(item, parent_id){
p_elem.textContent = item.get("displayName"); p_elem.textContent = item.get("displayName");
} }
p_elem.target = "_blank"; p_elem.target = "_blank";
active_elem.appendChild(p_elem); active_elem.appendChild(p_elem);
let img = document.createElement("img"); let img = document.createElement("img");
@ -674,7 +517,14 @@ function displayExpandedItem(item, parent_id){
active_elem.appendChild(bckgrd); active_elem.appendChild(bckgrd);
bckgrd.appendChild(img); bckgrd.appendChild(img);
} }
} else if (id === "lore") { } else {
let p_elem;
if ( !(item.get("tier") === "Crafted" && item.get("category") === "armor" && id === "hp") && (!skp_order.includes(id)) || (skp_order.includes(id) && item.get("tier") !== "Crafted" && active_elem.nodeName === "DIV") ) { //skp warp
p_elem = displayFixedID(active_elem, id, item.get(id), elemental_format);
} else if (item.get("tier") === "Crafted" && item.get("category") === "armor" && id === "hp") {
p_elem = displayFixedID(active_elem, id, item.get(id+"Low")+"-"+item.get(id), elemental_format);
}
if (id === "lore") {
p_elem.style = "font-style: italic"; p_elem.style = "font-style: italic";
p_elem.classList.add("lore"); p_elem.classList.add("lore");
} 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
@ -697,25 +547,7 @@ function displayExpandedItem(item, parent_id){
row.appendChild(boost); row.appendChild(boost);
p_elem.appendChild(row); p_elem.appendChild(row);
} else if ( item.get("tier") === "Crafted" && active_elem.nodeName === "TABLE") { } else if ( item.get("tier") === "Crafted" && active_elem.nodeName === "TABLE") {
let row = document.createElement('tr'); let row = displayRolledID(item, id, elemental_format);
let min_elem = document.createElement('td');
min_elem.classList.add('left');
min_elem.classList.add( item.get("minRolls").get(id) < 0 ? "negative" : "positive");
min_elem.textContent = item.get("minRolls").get(id) + idSuffixes[id];
row.appendChild(min_elem);
let desc_elem = document.createElement('td');
desc_elem.classList.add('center');
//TODO elemental format jank
desc_elem.textContent = idPrefixes[id];
row.appendChild(desc_elem);
let max_elem = document.createElement('td');
max_elem.classList.add('right');
max_elem.classList.add( item.get("maxRolls").get(id) < 0 ? "negative" : "positive");
max_elem.textContent = item.get("maxRolls").get(id) + idSuffixes[id];
row.appendChild(max_elem);
active_elem.appendChild(row); active_elem.appendChild(row);
} }
} else if (id === "restrict") { } else if (id === "restrict") {
@ -737,35 +569,7 @@ function displayExpandedItem(item, parent_id){
displayFixedID(active_elem, id, item.get("minRolls").get(id), elemental_format, style); displayFixedID(active_elem, id, item.get("minRolls").get(id), elemental_format, style);
} }
else { else {
let row = document.createElement('tr'); let row = displayRolledID(item, id, elemental_format);
let min_elem = document.createElement('td');
min_elem.classList.add('left');
min_elem.classList.add(style);
min_elem.textContent = item.get("minRolls").get(id) + idSuffixes[id];
row.appendChild(min_elem);
let desc_elem = document.createElement('td');
desc_elem.classList.add('center');
//TODO elemental format jank
if (elemental_format) {
apply_elemental_format(desc_elem, id);
}
else {
desc_elem.textContent = idPrefixes[id];
}
row.appendChild(desc_elem);
if (item.get("maxRolls").get(id) > 0) {
style = reversedIDs.includes(id) ? "negative" : "positive";
} else if (item.get("maxRolls").get(id) < 0 ) {
style = reversedIDs.includes(id) ? "positive" : "negative";
}
let max_elem = document.createElement('td');
max_elem.classList.add('right');
max_elem.classList.add(style);
max_elem.textContent = item.get("maxRolls").get(id) + idSuffixes[id];
row.appendChild(max_elem);
active_elem.appendChild(row); active_elem.appendChild(row);
} }
}else{ }else{
@ -1223,49 +1027,7 @@ function displayExpandedIngredient(ingred, parent_id) {
} else if (command === "ids") { //warp } else if (command === "ids") { //warp
for (let [key,value] of ingred.get("ids").get("maxRolls")) { for (let [key,value] of ingred.get("ids").get("maxRolls")) {
if (value !== undefined && value != 0) { if (value !== undefined && value != 0) {
value = ingred.get("ids").get("minRolls").get(key); let row = displayRolledID(ingred.get("ids"), key, false, "auto");
if(value > 0) {
style = "positive";
} else if (value <= 0) {
style = "negative";
}
if(reversedIDs.includes(key)){
style === "positive" ? style = "negative" : style = "positive";
}
let row = document.createElement('tr');
row.classList.add("center");
let min_elem = document.createElement('td');
min_elem.classList.add('left');
min_elem.classList.add(style);
min_elem.textContent = value + idSuffixes[key];
row.appendChild(min_elem);
let desc_elem = document.createElement('td');
desc_elem.classList.add('center');
//TODO elemental format jank
if (elemental_format) {
apply_elemental_format(desc_elem, key);
}
else {
desc_elem.textContent = idPrefixes[key];
}
row.appendChild(desc_elem);
let max_elem = document.createElement('td');
value = ingred.get("ids").get("maxRolls").get(key);
if(value > 0) {
style = "positive";
} else if (value <= 0) {
style = "negative";
}
if(reversedIDs.includes(key)){
style === "positive" ? style = "negative" : style = "positive";
}
max_elem.classList.add('right');
max_elem.classList.add(style);
max_elem.textContent = value + idSuffixes[key];
row.appendChild(max_elem);
active_elem.appendChild(row); active_elem.appendChild(row);
} }
} }
@ -1351,12 +1113,45 @@ function displayNextCosts(parent_id, build) {
} }
} }
function displayRolledID(item, id, elemental_format) {
let row = document.createElement('tr');
let min_elem = document.createElement('td');
min_elem.classList.add('left');
let id_min = item.get("minRolls").get(id)
let style = id_min < 0 ? "negative" : "positive";
if(reversedIDs.includes(id)){
style === "positive" ? style = "negative" : style = "positive";
}
min_elem.classList.add(style);
min_elem.textContent = id_min + idSuffixes[id];
row.appendChild(min_elem);
let desc_elem = document.createElement('td');
desc_elem.classList.add('center');
//TODO elemental format jank
if (elemental_format) {
apply_elemental_format(desc_elem, id);
}
else {
desc_elem.textContent = idPrefixes[id];
}
row.appendChild(desc_elem);
let max_elem = document.createElement('td');
let id_max = item.get("maxRolls").get(id)
max_elem.classList.add('right');
style = id_max < 0 ? "negative" : "positive";
if(reversedIDs.includes(id)){
style === "positive" ? style = "negative" : style = "positive";
}
max_elem.classList.add(style);
max_elem.textContent = id_max + idSuffixes[id];
row.appendChild(max_elem);
return row;
}
function displayFixedID(active, id, value, elemental_format, style) { function displayFixedID(active, id, value, elemental_format, style) {
if (style) { if (style) {
/*if(reversedIDs.filter(e => e !== "atkTier").includes(id)){
style === "positive" ? style = "negative" : style = "positive";
}*/
let row = document.createElement('tr'); let row = document.createElement('tr');
let desc_elem = document.createElement('td'); let desc_elem = document.createElement('td');
desc_elem.classList.add('left'); desc_elem.classList.add('left');

384
display_constants.js Normal file
View file

@ -0,0 +1,384 @@
let nonRolledIDs = [
"name",
"lore",
"displayName",
"tier",
"set",
"slots",
"type",
"material",
"drop",
"quest",
"restrict",
"nDam",
"fDam",
"wDam",
"aDam",
"tDam",
"eDam",
"atkSpd",
"hp",
"fDef",
"wDef",
"aDef",
"tDef",
"eDef",
"lvl",
"classReq",
"strReq",
"dexReq",
"intReq",
"defReq",
"agiReq","str",
"dex",
"int",
"agi",
"def",
"fixID",
"category",
"id",
"skillpoints",
"reqs",
"nDam_",
"fDam_",
"wDam_",
"aDam_",
"tDam_",
"eDam_",
"majorIds"];
let rolledIDs = [
"hprPct",
"mr",
"sdPct",
"mdPct",
"ls",
"ms",
"xpb",
"lb",
"ref",
"thorns",
"expd",
"spd",
"atkTier",
"poison",
"hpBonus",
"spRegen",
"eSteal",
"hprRaw",
"sdRaw",
"mdRaw",
"fDamPct",
"wDamPct",
"aDamPct",
"tDamPct",
"eDamPct",
"fDefPct",
"wDefPct",
"aDefPct",
"tDefPct",
"eDefPct",
"spPct1",
"spRaw1",
"spPct2",
"spRaw2",
"spPct3",
"spRaw3",
"spPct4",
"spRaw4",
"rainbowRaw",
"sprint",
"sprintReg",
"jh",
"lq",
"gXp",
"gSpd"
];
let reversedIDs = [ "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ];
let colorMap = new Map(
[
["Normal", "#fff"],
["Unique", "#ff5"],
["Rare","#f5f"],
["Legendary","#5ff"],
["Fabled","#f55"],
["Mythic","#a0a"],
["Crafted","#0aa"],
["Custom","#0aa"],
["Set","#5f5"]
]
);
let idPrefixes = {"displayName": "",
"lvl":"Combat Level Min: ",
"classReq":"Class Req: ",
"strReq":"Strength Min: ",
"dexReq":"Dexterity Min: ",
"intReq":"Intelligence Min: ",
"defReq":"Defense Min: ",
"agiReq":"Agility Min: ",
"nDam_":"Neutral Damage: ",
"eDam_":"Earth Damage: ",
"tDam_":"Thunder Damage: ",
"wDam_":"Water Damage: ",
"fDam_":"Fire Damage: ",
"aDam_":"Air Damage: ",
"atkSpd":"Attack Speed: ",
"hp":"Health : ",
"eDef":"Earth Defense: ",
"tDef":"Thunder Defense: ",
"wDef":"Water Defense: ",
"fDef":"Fire Defense: ",
"aDef":"Air Defense: ",
"str":"Strength: ",
"dex":"Dexterity: ",
"int":"Intelligence: ",
"def":"Defense: ","agi":"Agility: ",
"hpBonus":"Health Bonus: ",
"hprRaw":"Health Regen Raw: ",
"hprPct":"Health Regen %: ",
"sdRaw":"Raw Spell Damage: ",
"sdPct":"Spell Damage %: ",
"mdRaw":"Raw Melee Damage: ",
"mdPct":"Melee Damage %: ",
"mr":"Mana Regen: ",
"ms":"Mana Steal: ",
"ref":"Reflection: ",
"ls":"Life Steal: ",
"poison":"Poison: ",
"thorns":"Thorns: ",
"expd":"Exploding: ",
"spd":"Walk Speed Bonus: ",
"atkTier":"Attack Speed Bonus: ",
"eDamPct":"Earth Damage %: ",
"tDamPct":"Thunder Damage %: ",
"wDamPct":"Water Damage %: ",
"fDamPct":"Fire Damage %: ",
"aDamPct":"Air Damage %: ",
"eDefPct":"Earth Defense %: ",
"tDefPct":"Thunder Defense %: ",
"wDefPct":"Water Defense %: ",
"fDefPct":"Fire Defense %: ",
"aDefPct":"Air Defense %: ",
"spPct1":"1st Spell Cost %: ",
"spRaw1":"1st Spell Cost Raw: ",
"spPct2":"2nd Spell Cost %: ",
"spRaw2":"2nd Spell Cost Raw: ",
"spPct3":"3rd Spell Cost %: ",
"spRaw3":"3rd Spell Cost Raw: ",
"spPct4":"4th Spell Cost %: ",
"spRaw4":"4th Spell Cost Raw: ",
"rainbowRaw":"Rainbow Spell Damage Raw: ",
"sprint":"Sprint Bonus: ",
"sprintReg":"Sprint Regen Bonus: ",
"jh":"Jump Height: ",
"xpb":"Combat XP Bonus: ",
"lb":"Loot Bonus: ",
"lq":"Loot Quality: ",
"spRegen":"Soul Point Regen: ",
"eSteal":"Stealing: ",
"gXp":"Gathering XP Bonus: ",
"gSpd":"Gathering Speed Bonus: ",
"slots":"Powder Slots: ",
"set":"Set: ",
"quest":"Quest Req: ",
"restrict":"",
"lore": ""
};
let idSuffixes = {"displayName": "",
"lvl":"",
"classReq":"",
"strReq":"",
"dexReq":"",
"intReq":"",
"defReq":"",
"agiReq":"",
"nDam_":"",
"eDam_":"",
"tDam_":"",
"wDam_":"",
"fDam_":"",
"aDam_":"",
"atkSpd":"",
"hp":"",
"eDef":"",
"tDef":"",
"wDef":"",
"fDef":"",
"aDef":"",
"str":"",
"dex":"",
"int":"",
"def":"",
"agi":"",
"hpBonus":"",
"hprRaw":"",
"hprPct":"%",
"sdRaw":"",
"sdPct":"%",
"mdRaw":"",
"mdPct":"%",
"mr":"/5s",
"ms":"/3s",
"ref":"%",
"ls":"/3s",
"poison":"/3s",
"thorns":"%",
"expd":"%",
"spd":"%",
"atkTier":" tier",
"eDamPct":"%",
"tDamPct":"%",
"wDamPct":"%",
"fDamPct":"%",
"aDamPct":"%",
"eDefPct":"%",
"tDefPct":"%",
"wDefPct":"%",
"fDefPct":"%",
"aDefPct":"%",
"spPct1":"%",
"spRaw1":"",
"spPct2":"%",
"spRaw2":"",
"spPct3":"%",
"spRaw3":"",
"spPct4":"%",
"spRaw4":"",
"rainbowRaw":"",
"sprint":"%",
"sprintReg":"%",
"jh":"",
"xpb":"%",
"lb":"%",
"lq":"%",
"spRegen":"%",
"eSteal":"%",
"gXp":"%",
"gSpd":"%",
"slots":"",
"set":" set.",
"quest":"",
"restrict":"",
"lore": ""
};
//Used for item IDs and ingredient id field IDs
//Used for ingredient IDs - name, lvl, tier. As of now, not used.
/*let ingPrefixes = {"name": "", "lvl": "", "tier": ""};
let ingSuffixes = {"name": "", "lvl": "", "tier": ""}*/
//Used for ingredient consumableIDs
let consumableIDPrefixes = {
"charges": "Charges: ",
"dura": "Duration: "
}
let consumableIDSuffixes = {
"charges": "",
"dura": " sec."
}
//Used for ingredient itemIDs
let itemIDPrefixes = {
"dura": "Durability: ",
"strReq": "Strength Min: ",
"dexReq": "Dexterity Min: ",
"intReq": "Intelligence Min: ",
"defReq": "Defense Min: ",
"agiReq": "Agility Min: "
}
//Used for ingredient posMods IDs
let posModPrefixes = {
"left":"Effectiveness Left: ",
"right":"EFfectiveness Right: ",
"above":"Effectiveness Above: ",
"under":"Effectiveness Under: ",
"touching":"EFfectiveness Touching: ",
"notTouching":"Effectiveness Not Touching: "
}
let posModSuffixes = {
"left":"%",
"right":"%",
"above":"%",
"under":"%",
"touching":"%",
"notTouching":"%"
}
/*
* Display commands
*/
let build_overall_display_commands = [
"#table",
"str", "dex", "int", "def", "agi",
"mr", "ms",
"hprRaw", "hprPct",
"sdRaw", "sdPct",
"mdRaw", "mdPct",
"ref", "thorns",
"ls",
"poison",
"expd",
"spd",
"atkTier",
"!elemental",
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw",
"sprint", "sprintReg",
"jh",
"xpb", "lb", "lq",
"spRegen",
"eSteal",
"gXp", "gSpd",
];
let item_display_commands = [
"#cdiv",
"displayName",
//"type", //REPLACE THIS WITH SKIN
"#ldiv",
"atkSpd",
"#ldiv",
"!elemental",
"hp",
"nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_",
"fDef", "wDef", "aDef", "tDef", "eDef",
"!elemental",
"#ldiv",
"classReq",
"lvl",
"strReq", "dexReq", "intReq", "defReq","agiReq",
"#ldiv",
"str", "dex", "int", "def", "agi",
"#table",
"str", "dex", "int", "def", "agi", //jank lmao
"hpBonus",
"hprRaw", "hprPct",
"sdRaw", "sdPct",
"mdRaw", "mdPct",
"mr", "ms",
"ref", "thorns",
"ls",
"poison",
"expd",
"spd",
"atkTier",
"!elemental",
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
"fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw",
"sprint", "sprintReg",
"jh",
"xpb", "lb", "lq",
"spRegen",
"eSteal",
"gXp", "gSpd",
"#ldiv",
"majorIds",
"slots",
"set",
"lore",
"quest",
"restrict"
];

View file

@ -1017,6 +1017,7 @@
<script type="text/javascript" src="powders.js"></script> <script type="text/javascript" src="powders.js"></script>
<script type="text/javascript" src="skillpoints.js"></script> <script type="text/javascript" src="skillpoints.js"></script>
<script type="text/javascript" src="damage_calc.js"></script> <script type="text/javascript" src="damage_calc.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="load.js"></script> <script type="text/javascript" src="load.js"></script>
<script type="text/javascript" src="load_ing.js"></script> <script type="text/javascript" src="load_ing.js"></script>

View file

@ -62,6 +62,7 @@
<script type="text/javascript" src="load_ing.js"></script> <script type="text/javascript" src="load_ing.js"></script>
<script type="text/javascript" src="crafter.js"></script> <script type="text/javascript" src="crafter.js"></script>
<script type="text/javascript" src="craft.js"></script> <script type="text/javascript" src="craft.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="custom.js"></script> <script type="text/javascript" src="custom.js"></script>
<script type="text/javascript" src="customizer.js"></script> <script type="text/javascript" src="customizer.js"></script>

View file

@ -127,6 +127,7 @@
<script type="text/javascript" src="loadheader.js"></script> <script type="text/javascript" src="loadheader.js"></script>
<script type="text/javascript" src="icons.js"></script> <script type="text/javascript" src="icons.js"></script>
<script type="text/javascript" src="/damage_calc.js"></script> <script type="text/javascript" src="/damage_calc.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="/display.js"></script> <script type="text/javascript" src="/display.js"></script>
<script type="text/javascript" src="/query.js"></script> <script type="text/javascript" src="/query.js"></script>
<script type="text/javascript" src="/load.js"></script> <script type="text/javascript" src="/load.js"></script>

View file

@ -64,6 +64,7 @@
<script type="text/javascript" src="loadheader.js"></script> <script type="text/javascript" src="loadheader.js"></script>
<script type="text/javascript" src="icons.js"></script> <script type="text/javascript" src="icons.js"></script>
<script type="text/javascript" src="damage_calc.js"></script> <script type="text/javascript" src="damage_calc.js"></script>
<script type="text/javascript" src="display_constants.js"></script>
<script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="display.js"></script>
<script type="text/javascript" src="query_2.js"></script> <script type="text/javascript" src="query_2.js"></script>
<script type="text/javascript" src="expr_parser.js"></script> <script type="text/javascript" src="expr_parser.js"></script>

View file

@ -180,7 +180,7 @@ function init_ing_maps() {
ing.displayName = ing.name ing.displayName = ing.name
ing.tier = 0; ing.tier = 0;
ing.lvl = 0; ing.lvl = 0;
ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING"]; ing.skills = ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"];
ing.ids = {}; ing.ids = {};
ing.isPowder = true; ing.isPowder = true;
ing.pid = 6*i + powderIngreds.indexOf(powderIng); ing.pid = 6*i + powderIngreds.indexOf(powderIng);