2021-01-09 00:56:07 +00:00
|
|
|
let nonRolledIDs = ["name", "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_"];
|
2021-01-09 11:15:28 +00:00
|
|
|
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"];
|
2021-01-07 22:44:52 +00:00
|
|
|
|
2021-01-09 12:47:25 +00:00
|
|
|
let reversedIDs = [ "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ];
|
|
|
|
|
2021-01-09 00:56:07 +00:00
|
|
|
function expandItem(item, powders){
|
2021-01-07 22:44:52 +00:00
|
|
|
let minRolls = new Map();
|
|
|
|
let maxRolls = new Map();
|
|
|
|
let expandedItem = new Map();
|
|
|
|
if(item.fixID){ //The item has fixed IDs.
|
|
|
|
expandedItem.set("fixID",true);
|
|
|
|
for (const id of rolledIDs){ //all rolled IDs are numerical
|
2021-01-08 05:36:57 +00:00
|
|
|
//if(item[id]) {
|
2021-01-07 22:44:52 +00:00
|
|
|
minRolls.set(id,item[id]);
|
|
|
|
maxRolls.set(id,item[id]);
|
2021-01-08 05:36:57 +00:00
|
|
|
//}
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
|
|
|
}else{ //The item does not have fixed IDs.
|
|
|
|
for (const id of rolledIDs){
|
2021-01-09 13:25:19 +00:00
|
|
|
if(item[id] > 0){ // positive rolled IDs
|
|
|
|
minRolls.set(id,idRound(item[id]*0.3));
|
|
|
|
maxRolls.set(id,idRound(item[id]*1.3));
|
|
|
|
}else if(item[id] < 0){ //negative rolled IDs
|
|
|
|
if (reversedIDs.includes(id)) {
|
2021-01-07 22:44:52 +00:00
|
|
|
maxRolls.set(id,idRound(item[id]*1.3));
|
2021-01-09 13:25:19 +00:00
|
|
|
minRolls.set(id,idRound(item[id]*0.7));
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
2021-01-09 13:25:19 +00:00
|
|
|
else {
|
|
|
|
minRolls.set(id,idRound(item[id]*1.3));
|
|
|
|
maxRolls.set(id,idRound(item[id]*0.7));
|
|
|
|
}
|
|
|
|
}else{//Id = 0
|
|
|
|
minRolls.set(id,0);
|
|
|
|
maxRolls.set(id,0);
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const id of nonRolledIDs){
|
2021-01-09 13:15:30 +00:00
|
|
|
expandedItem.set(id,item[id]);
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
|
|
|
expandedItem.set("minRolls",minRolls);
|
|
|
|
expandedItem.set("maxRolls",maxRolls);
|
2021-01-09 00:56:07 +00:00
|
|
|
expandedItem.set("powders", powders);
|
2021-01-07 22:44:52 +00:00
|
|
|
return expandedItem;
|
|
|
|
}
|
2021-01-08 17:30:36 +00:00
|
|
|
/*An independent helper function that rounds a rolled ID to the nearest integer OR brings the roll away from 0.
|
|
|
|
* @param id
|
|
|
|
*/
|
|
|
|
function idRound(id){
|
|
|
|
rounded = Math.round(id);
|
|
|
|
if(rounded == 0){
|
|
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
return rounded;
|
|
|
|
}
|
|
|
|
}
|
2021-01-09 11:56:10 +00:00
|
|
|
|
2021-01-09 12:47:25 +00:00
|
|
|
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":"Main Attack Neutral Damage: ", "mdPct":"Main Attack 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":""};
|
|
|
|
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":"/4s", "ms":"/4s", "ref":"%", "ls":"/4s", "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":""};
|
|
|
|
|
|
|
|
function apply_elemental_format(p_elem, id, suffix) {
|
|
|
|
suffix = (typeof suffix !== 'undefined') ? suffix : "";
|
|
|
|
// THIS IS SO JANK BUT IM TOO LAZY TO FIX IT TODO
|
|
|
|
let parts = idPrefixes[id].split(/ (.*)/);
|
|
|
|
let element_prefix = parts[0];
|
|
|
|
let desc = parts[1];
|
|
|
|
let i_elem = document.createElement('b');
|
|
|
|
i_elem.classList.add(element_prefix);
|
|
|
|
i_elem.textContent = element_prefix;
|
|
|
|
p_elem.appendChild(i_elem);
|
|
|
|
|
|
|
|
let i_elem2 = document.createElement('b');
|
|
|
|
i_elem2.textContent = " " + desc + suffix;
|
|
|
|
p_elem.appendChild(i_elem2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayBuildStats(build, parent_id){
|
|
|
|
// Commands to "script" the creation of nice formatting.
|
|
|
|
// #commands create a new element.
|
|
|
|
// !elemental is some janky hack for elemental damage.
|
|
|
|
// normals just display a thing.
|
|
|
|
|
|
|
|
let display_commands = [
|
|
|
|
"#ldiv",
|
|
|
|
"!elemental",
|
|
|
|
"hp",
|
|
|
|
"fDef", "wDef", "aDef", "tDef", "eDef",
|
|
|
|
"!elemental",
|
|
|
|
"#table",
|
|
|
|
"str", "dex", "int", "def", "agi",
|
|
|
|
"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",
|
|
|
|
];
|
|
|
|
|
|
|
|
// Clear the parent div.
|
|
|
|
setHTML(parent_id, "");
|
|
|
|
let parent_div = document.getElementById(parent_id);
|
|
|
|
|
|
|
|
let stats = build.statMap;
|
|
|
|
|
|
|
|
let active_elem;
|
|
|
|
let elemental_format = false;
|
|
|
|
|
|
|
|
//TODO this is put here for readability, consolidate with definition in build.js
|
|
|
|
let staticIDs = ["hp", "eDef", "tDef", "wDef", "fDef", "aDef"];
|
|
|
|
|
|
|
|
for (const command of display_commands) {
|
|
|
|
if (command.charAt(0) === "#") {
|
|
|
|
if (command === "#cdiv") {
|
|
|
|
active_elem = document.createElement('div');
|
|
|
|
active_elem.classList.add('itemcenter');
|
|
|
|
}
|
|
|
|
else if (command === "#ldiv") {
|
|
|
|
active_elem = document.createElement('div');
|
|
|
|
active_elem.classList.add('itemleft');
|
|
|
|
}
|
|
|
|
else if (command === "#table") {
|
|
|
|
active_elem = document.createElement('table');
|
|
|
|
active_elem.classList.add('itemtable');
|
|
|
|
}
|
|
|
|
parent_div.appendChild(active_elem);
|
|
|
|
}
|
|
|
|
else if (command.charAt(0) === "!") {
|
|
|
|
// TODO: This is sooo incredibly janky.....
|
|
|
|
if (command === "!elemental") {
|
|
|
|
elemental_format = !elemental_format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let id = command;
|
|
|
|
if (stats.get(id)) {
|
|
|
|
let style = null;
|
|
|
|
if (!staticIDs.includes(id)) {
|
|
|
|
style = "positive";
|
|
|
|
if (stats.get(id) < 0) {
|
|
|
|
style = "negative";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
displayFixedID(active_elem, id, stats.get(id), elemental_format, style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-07 22:44:52 +00:00
|
|
|
function displayExpandedItem(item, parent_id){
|
|
|
|
// Commands to "script" the creation of nice formatting.
|
|
|
|
// #commands create a new element.
|
2021-01-08 01:02:12 +00:00
|
|
|
// !elemental is some janky hack for elemental damage.
|
2021-01-07 22:44:52 +00:00
|
|
|
// normals just display a thing.
|
2021-01-09 00:56:07 +00:00
|
|
|
if (item.get("category") === "weapon") {
|
|
|
|
let stats = new Map();
|
|
|
|
stats.set("atkSpd", item.get("atkSpd"));
|
|
|
|
stats.set("damageBonus", [0, 0, 0, 0, 0]);
|
|
|
|
stats.set("damageRaw", [item.get("nDam"), item.get("eDam"), item.get("tDam"), item.get("wDam"), item.get("fDam"), item.get("aDam")]);
|
2021-01-09 03:53:57 +00:00
|
|
|
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, [0, 0, 0, 0, 0]);
|
2021-01-09 00:56:07 +00:00
|
|
|
let damages = results[2];
|
|
|
|
let damage_keys = [ "nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_" ];
|
|
|
|
for (const i in damage_keys) {
|
|
|
|
item.set(damage_keys[i], damages[i][0]+"-"+damages[i][1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-07 22:44:52 +00:00
|
|
|
let display_commands = [
|
|
|
|
"#cdiv",
|
|
|
|
"displayName",
|
|
|
|
"#ldiv",
|
|
|
|
"atkSpd",
|
|
|
|
"#ldiv",
|
2021-01-08 01:02:12 +00:00
|
|
|
"!elemental",
|
2021-01-08 01:14:56 +00:00
|
|
|
"hp",
|
2021-01-09 03:53:57 +00:00
|
|
|
"nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_",
|
|
|
|
"fDef", "wDef", "aDef", "tDef", "eDef",
|
2021-01-08 01:02:12 +00:00
|
|
|
"!elemental",
|
|
|
|
"#ldiv",
|
|
|
|
"classReq",
|
|
|
|
"lvl",
|
|
|
|
"strReq", "dexReq", "intReq", "defReq","agiReq",
|
|
|
|
"#ldiv",
|
2021-01-08 02:51:32 +00:00
|
|
|
"str", "dex", "int", "def", "agi",
|
2021-01-08 01:02:12 +00:00
|
|
|
"#table",
|
2021-01-07 22:44:52 +00:00
|
|
|
"hpBonus",
|
|
|
|
"hprRaw", "hprPct",
|
|
|
|
"sdRaw", "sdPct",
|
|
|
|
"mdRaw", "mdPct",
|
|
|
|
"mr", "ms",
|
|
|
|
"ref", "thorns",
|
|
|
|
"ls",
|
|
|
|
"poison",
|
2021-01-09 11:15:28 +00:00
|
|
|
"expd",
|
2021-01-07 22:44:52 +00:00
|
|
|
"spd",
|
|
|
|
"atkTier",
|
2021-01-08 01:02:12 +00:00
|
|
|
"!elemental",
|
2021-01-09 03:53:57 +00:00
|
|
|
"fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct",
|
|
|
|
"fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
|
2021-01-08 01:02:12 +00:00
|
|
|
"!elemental",
|
2021-01-07 22:44:52 +00:00
|
|
|
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
|
|
|
|
"rainbowRaw",
|
|
|
|
"sprint", "sprintReg",
|
|
|
|
"jh",
|
|
|
|
"xpb", "lb", "lq",
|
|
|
|
"spRegen",
|
|
|
|
"eSteal",
|
|
|
|
"gXp", "gSpd",
|
2021-01-08 01:02:12 +00:00
|
|
|
"#ldiv",
|
2021-01-07 22:44:52 +00:00
|
|
|
"slots",
|
|
|
|
"set",
|
|
|
|
"quest",
|
|
|
|
"restrict"];
|
|
|
|
|
|
|
|
// Clear the parent div.
|
|
|
|
setHTML(parent_id, "");
|
|
|
|
let parent_div = document.getElementById(parent_id);
|
|
|
|
|
|
|
|
let active_elem;
|
2021-01-08 01:02:12 +00:00
|
|
|
let fix_id = item.has("fixID") && item.get("fixID");
|
|
|
|
let elemental_format = false;
|
2021-01-07 22:44:52 +00:00
|
|
|
for (const command of display_commands) {
|
|
|
|
if (command.charAt(0) === "#") {
|
|
|
|
if (command === "#cdiv") {
|
|
|
|
active_elem = document.createElement('div');
|
|
|
|
active_elem.classList.add('itemcenter');
|
|
|
|
}
|
|
|
|
else if (command === "#ldiv") {
|
|
|
|
active_elem = document.createElement('div');
|
|
|
|
active_elem.classList.add('itemleft');
|
|
|
|
}
|
2021-01-08 01:02:12 +00:00
|
|
|
else if (command === "#table") {
|
|
|
|
active_elem = document.createElement('table');
|
|
|
|
active_elem.classList.add('itemtable');
|
|
|
|
}
|
2021-01-07 22:44:52 +00:00
|
|
|
parent_div.appendChild(active_elem);
|
|
|
|
}
|
2021-01-08 01:02:12 +00:00
|
|
|
else if (command.charAt(0) === "!") {
|
|
|
|
// TODO: This is sooo incredibly janky.....
|
|
|
|
if (command === "!elemental") {
|
|
|
|
elemental_format = !elemental_format;
|
|
|
|
}
|
|
|
|
}
|
2021-01-07 22:44:52 +00:00
|
|
|
else {
|
|
|
|
let id = command;
|
|
|
|
if(nonRolledIDs.includes(id) && item.get(id)){//nonRolledID & non-0/non-null/non-und ID
|
2021-01-09 12:47:25 +00:00
|
|
|
displayFixedID(active_elem, id, item.get(id), elemental_format);
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
2021-01-08 01:02:12 +00:00
|
|
|
else if(rolledIDs.includes(id)&& item.get("minRolls").get(id)){ // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID
|
|
|
|
let style = "positive";
|
|
|
|
if (item.get("minRolls").get(id) < 0) {
|
|
|
|
style = "negative";
|
|
|
|
}
|
|
|
|
if (fix_id) {
|
2021-01-09 12:47:25 +00:00
|
|
|
let p_elem = displayFixedID(active_elem, id, item.get("minRolls").get(id), elemental_format, style);
|
|
|
|
if (id === "slots") {
|
|
|
|
// HACK TO MAKE POWDERS DISPLAY NICE!! TODO
|
|
|
|
p_elem.textContent = idPrefixes[id].concat(value, idSuffixes[id]) +
|
|
|
|
" [ " + item.get("powders").map(x => powderNames.get(x)) + " ]";
|
2021-01-08 01:02:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2021-01-09 12:47:25 +00:00
|
|
|
let row = document.createElement('tr');
|
2021-01-08 01:02:12 +00:00
|
|
|
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');
|
2021-01-09 03:53:57 +00:00
|
|
|
//TODO elemental format jank
|
2021-01-08 01:02:12 +00:00
|
|
|
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');
|
|
|
|
max_elem.classList.add('right');
|
|
|
|
max_elem.classList.add(style);
|
|
|
|
max_elem.textContent = item.get("maxRolls").get(id) + idSuffixes[id];
|
|
|
|
row.appendChild(max_elem);
|
2021-01-09 12:47:25 +00:00
|
|
|
active_elem.appendChild(row);
|
2021-01-08 01:02:12 +00:00
|
|
|
}
|
|
|
|
}//Just don't do anything if else
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-08 01:02:12 +00:00
|
|
|
let item_desc_elem = document.createElement('p');
|
|
|
|
item_desc_elem.classList.add('itemp');
|
|
|
|
item_desc_elem.classList.add('left');
|
|
|
|
item_desc_elem.textContent = item.get("tier")+" "+item.get("type");
|
|
|
|
parent_div.append(item_desc_elem);
|
2021-01-07 22:44:52 +00:00
|
|
|
}
|
2021-01-09 08:52:58 +00:00
|
|
|
|
2021-01-09 12:47:25 +00:00
|
|
|
function displayFixedID(active, id, value, elemental_format, style) {
|
|
|
|
if (style) {
|
|
|
|
let row = document.createElement('tr');
|
|
|
|
let desc_elem = document.createElement('td');
|
|
|
|
desc_elem.classList.add('left');
|
|
|
|
if (elemental_format) {
|
|
|
|
apply_elemental_format(desc_elem, id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
desc_elem.textContent = idPrefixes[id];
|
|
|
|
}
|
|
|
|
row.appendChild(desc_elem);
|
2021-01-09 11:56:10 +00:00
|
|
|
|
2021-01-09 12:47:25 +00:00
|
|
|
let value_elem = document.createElement('td');
|
|
|
|
value_elem.classList.add('right');
|
|
|
|
value_elem.classList.add(style);
|
|
|
|
value_elem.textContent = value + idSuffixes[id];
|
|
|
|
row.appendChild(value_elem);
|
|
|
|
active.appendChild(row);
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// HACK TO AVOID DISPLAYING ZERO DAMAGE! TODO
|
|
|
|
if (value === "0-0") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let p_elem = document.createElement('p');
|
|
|
|
p_elem.classList.add('itemp');
|
|
|
|
if (elemental_format) {
|
|
|
|
apply_elemental_format(p_elem, id, value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p_elem.textContent = idPrefixes[id].concat(value, idSuffixes[id]);
|
|
|
|
}
|
|
|
|
active.appendChild(p_elem);
|
|
|
|
return p_elem;
|
|
|
|
}
|
2021-01-09 11:56:10 +00:00
|
|
|
}
|
|
|
|
|
2021-01-09 08:52:58 +00:00
|
|
|
function displaySpellDamage(parent_elem, build, spell, spellIdx) {
|
|
|
|
parent_elem.textContent = "";
|
|
|
|
|
|
|
|
const stats = build.statMap;
|
|
|
|
let title_elem = document.createElement("p");
|
|
|
|
title_elem.classList.add('center');
|
|
|
|
if (spellIdx != 0) {
|
|
|
|
title_elem.textContent = spell.title + " (" + build.getSpellCost(spellIdx, spell.cost) + ")";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
title_elem.textContent = spell.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent_elem.append(title_elem);
|
|
|
|
let critChance = skillPointsToPercentage(build.total_skillpoints[1]);
|
|
|
|
|
2021-01-09 09:35:18 +00:00
|
|
|
let save_damages = [];
|
|
|
|
|
2021-01-09 08:52:58 +00:00
|
|
|
for (const part of spell.parts) {
|
|
|
|
parent_elem.append(document.createElement("br"));
|
|
|
|
let part_div = document.createElement("p");
|
|
|
|
parent_elem.append(part_div);
|
|
|
|
|
|
|
|
let subtitle_elem = document.createElement("p");
|
|
|
|
subtitle_elem.textContent = part.subtitle;
|
|
|
|
part_div.append(subtitle_elem);
|
|
|
|
if (part.type === "damage") {
|
|
|
|
|
|
|
|
let _results = calculateSpellDamage(stats, part.conversion,
|
|
|
|
stats.get("sdRaw"), stats.get("sdPct"),
|
|
|
|
part.multiplier / 100, build.weapon, build.total_skillpoints);
|
|
|
|
let totalDamNormal = _results[0];
|
|
|
|
let totalDamCrit = _results[1];
|
|
|
|
let results = _results[2];
|
|
|
|
for (let i = 0; i < 6; ++i) {
|
|
|
|
for (let j in results[i]) {
|
2021-01-09 11:01:57 +00:00
|
|
|
results[i][j] = results[i][j].toFixed(2);
|
2021-01-09 08:52:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
let nonCritAverage = (totalDamNormal[0]+totalDamNormal[1])/2;
|
|
|
|
let critAverage = (totalDamCrit[0]+totalDamCrit[1])/2;
|
2021-01-09 09:35:18 +00:00
|
|
|
let averageDamage = (1-critChance)*nonCritAverage+critChance*critAverage;
|
2021-01-09 08:52:58 +00:00
|
|
|
|
2021-01-09 09:35:18 +00:00
|
|
|
let averageLabel = document.createElement("p");
|
2021-01-09 11:01:57 +00:00
|
|
|
averageLabel.textContent = "Average: "+averageDamage.toFixed(2);
|
2021-01-09 09:35:18 +00:00
|
|
|
averageLabel.classList.add("damageSubtitle");
|
|
|
|
part_div.append(averageLabel);
|
2021-01-09 08:52:58 +00:00
|
|
|
|
|
|
|
let nonCritLabel = document.createElement("p");
|
2021-01-09 11:01:57 +00:00
|
|
|
nonCritLabel.textContent = "Non-Crit Average: "+nonCritAverage.toFixed(2);
|
2021-01-09 08:52:58 +00:00
|
|
|
nonCritLabel.classList.add("damageSubtitle");
|
|
|
|
part_div.append(nonCritLabel);
|
|
|
|
|
|
|
|
let damageClasses = ["Neutral","Earth","Thunder","Water","Fire","Air"];
|
|
|
|
for (let i = 0; i < 6; i++){
|
2021-01-09 11:01:57 +00:00
|
|
|
if (results[i][1] > 0){
|
2021-01-09 08:52:58 +00:00
|
|
|
let p = document.createElement("p");
|
|
|
|
p.classList.add("damagep");
|
|
|
|
p.classList.add(damageClasses[i]);
|
|
|
|
p.textContent = results[i][0]+"-"+results[i][1];
|
|
|
|
part_div.append(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//part_div.append(document.createElement("br"));
|
|
|
|
let critLabel = document.createElement("p");
|
2021-01-09 11:01:57 +00:00
|
|
|
critLabel.textContent = "Crit Average: "+critAverage.toFixed(2);
|
2021-01-09 08:52:58 +00:00
|
|
|
critLabel.classList.add("damageSubtitle");
|
|
|
|
part_div.append(critLabel);
|
|
|
|
|
|
|
|
for (let i = 0; i < 6; i++){
|
2021-01-09 11:01:57 +00:00
|
|
|
if (results[i][1] > 0){
|
2021-01-09 08:52:58 +00:00
|
|
|
let p = document.createElement("p");
|
|
|
|
p.classList.add("damagep");
|
|
|
|
p.classList.add(damageClasses[i]);
|
|
|
|
p.textContent = results[i][2]+"-"+results[i][3];
|
|
|
|
part_div.append(p);
|
|
|
|
}
|
|
|
|
}
|
2021-01-09 09:35:18 +00:00
|
|
|
save_damages.push(averageDamage);
|
|
|
|
}
|
2021-01-09 11:56:10 +00:00
|
|
|
else if (part.type == "heal") {
|
|
|
|
let heal_amount = part.strength * build.getHealth() * Math.max(0, Math.min(1.5, 1 + 0.05 * stats.get("wDamPct")));
|
|
|
|
let healLabel = document.createElement("p");
|
|
|
|
healLabel.textContent = heal_amount;
|
|
|
|
healLabel.classList.add("damagep");
|
|
|
|
part_div.append(healLabel);
|
|
|
|
}
|
2021-01-09 09:35:18 +00:00
|
|
|
else if (part.type === "total") {
|
|
|
|
let total_damage = 0;
|
|
|
|
for (let i in part.factors) {
|
2021-01-09 09:37:01 +00:00
|
|
|
total_damage += save_damages[i] * part.factors[i];
|
2021-01-09 09:35:18 +00:00
|
|
|
}
|
|
|
|
let averageLabel = document.createElement("p");
|
2021-01-09 11:01:57 +00:00
|
|
|
averageLabel.textContent = "Average: "+total_damage.toFixed(2);
|
2021-01-09 09:35:18 +00:00
|
|
|
averageLabel.classList.add("damageSubtitle");
|
|
|
|
part_div.append(averageLabel);
|
2021-01-09 08:52:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|