fixed pos raw and <-100 % issue, added external buffs + powder specials section, added buttons & functionality for all spell-based external buffs

This commit is contained in:
ferricles 2021-01-11 23:11:20 -08:00
parent a02cd0c794
commit 43aba4a720
7 changed files with 67 additions and 7 deletions

View file

@ -173,7 +173,7 @@ class Build{
}
// 0 for melee damage.
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], stats.get("mdRaw"), stats.get("mdPct"), 0, this.weapon, this.total_skillpoints);
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], stats.get("mdRaw"), stats.get("mdPct"), 0, this.weapon, this.total_skillpoints, this.damageMultiplier);
let dex = this.total_skillpoints[1];

View file

@ -1,6 +1,7 @@
const damageMultipliers = new Map([ ["allytotem", .35], ["yourtotem", .35], ["vanish", 0.80], ["warscream", 0.10] ]);
// Calculate spell damage given a spell elemental conversion table, and a spell multiplier.
// If spell mult is 0, its melee damage and we don't multiply by attack speed.
function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, spellMultiplier, weapon, total_skillpoints) {
function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, spellMultiplier, weapon, total_skillpoints, damageMultiplier) {
// Array of neutral + ewtfa damages. Each entry is a pair (min, max).
let damages = [];
for (const damage_string of stats.get("damageRaw")) {
@ -39,7 +40,7 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier,
damages[element+1][1] += powder.max;
}
let damageMult = 1;
let damageMult = damageMultiplier;
let melee = false;
// If we are doing melee calculations:
if (spellMultiplier == 0) {
@ -99,6 +100,8 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier,
return [totalDamNorm, totalDamCrit, damages_results];
}
const spell_table = {
"wand": [
{ title: "Heal", cost: 6, parts: [

View file

@ -273,7 +273,7 @@ function displayExpandedItem(item, parent_id){
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")]);
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, [0, 0, 0, 0, 0]);
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, [0, 0, 0, 0, 0], 1);
let damages = results[2];
let damage_keys = [ "nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_" ];
for (const i in damage_keys) {
@ -988,7 +988,7 @@ function displaySpellDamage(parent_elem, overallparent_elem, build, spell, spell
let _results = calculateSpellDamage(stats, part.conversion,
stats.get("sdRaw"), stats.get("sdPct"),
part.multiplier / 100, build.weapon, build.total_skillpoints);
part.multiplier / 100, build.weapon, build.total_skillpoints, build.damageMultiplier);
let totalDamNormal = _results[0];
let totalDamCrit = _results[1];
let results = _results[2];

View file

@ -176,6 +176,37 @@
Summary:
</div>
<br><br>
<div class="externalBuffs" id="buff-box">
<table>
<tr>
<p class = "buffs-title itemp title">
Spell Boosts & Powder Specials:
</p>
</tr>
<tr>
<td>
<button class = "button toggleOff" id = "vanish-boost" onclick = "updateBoosts('vanish-boost')">
Vanish Boost (+80%)
</button>
</td>
<td>
<button class = "button toggleOff" id = "warscream-boost" onclick = "updateBoosts('warscream-boost')">
War Scream (+10%)
</button>
</td>
<td>
<button class = "button toggleOff" id = "yourtotem-boost" onclick = "updateBoosts('yourtotem-boost')">
Your Totem (+35%)
</button>
</td>
<td>
<button class = "button toggleOff" id = "allytotem-boost" onclick = "updateBoosts('allytotem-boost')">
Ally Totem (+15%)
</button>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="build-overall-container">

View file

@ -236,3 +236,8 @@ input {
.restrict, .warning {
color: #ff8180;
}
button.toggleOn{
background-color:#0a0;
border: 3 px solid rgb(0, 70, 0);
}

23
test.js
View file

@ -345,6 +345,8 @@ function decodeBuild(url_tag) {
}
}
/* Stores the entire build in a string using B64 encryption and adds it to the URL.
*/
function encodeBuild() {
if (player_build) {
let build_string = "3_" + Base64.fromIntN(player_build.helmet.get("id"), 3) +
@ -445,6 +447,8 @@ function calculateBuild(save_skp, skp){
}
/* Updates all build statistics based on (for now) the skillpoint input fields and then calculates build stats.
*/
function updateStats() {
//WILL BREAK WEBSITE IF NO BUILD HAS BEEN INITIALIZED! @HPP
let skillpoints = player_build.total_skillpoints;
@ -459,9 +463,26 @@ function updateStats() {
player_build.assigned_skillpoints += delta_total;
calculateBuildStats();
}
/* Updates all external boosts (boosts from spells + powders)
*/
function updateBoosts(buttonId) {
let elem = document.getElementById(buttonId);
if (elem.classList.contains("toggleOn")) {
player_build.damageMultiplier -= damageMultipliers.get(buttonId.split("-")[0]);
elem.classList.remove("toggleOn");
elem.classList.add("toggleOff");
}else{
player_build.damageMultiplier += damageMultipliers.get(buttonId.split("-")[0]);
elem.classList.remove("toggleOff");
elem.classList.add("toggleOn");
}
//displayPowderBoosts(); TODO WRITE
calculateBuildStats();
}
/* Calculates all build statistics and updates the entire display.
*/
function calculateBuildStats() {
const assigned = player_build.base_skillpoints;
const skillpoints = player_build.total_skillpoints;
let skp_effects = ["% more damage dealt.","% chance to crit.","% spell cost reduction.","% less damage taken.","% chance to dodge."];

View file

@ -119,7 +119,7 @@ function rawToPct(raw, pct){
if (raw < 0){
final = (Math.min(0, raw - (raw * pct) ));
}else if(raw > 0){
final = (Math.max(0, raw + (raw * pct)));
final = raw + (raw * pct);
}else{ //do nothing - final's already 0
}
return final;