Show max-roll effect value in totals

This commit is contained in:
Jan Bader
2026-06-16 15:13:57 +02:00
parent 02e63d10dd
commit 9432b6a4ce
3 changed files with 42 additions and 8 deletions
+28 -3
View File
@@ -157,6 +157,7 @@ function updateAnalysis() {
const profile = PROFILES[state.profile];
const totals = calculateTotals();
const dps = calculateDps(totals, state.combatStyle);
const survivability = calculateSurvivability(totals);
const pieceScores = state.pieces.map((piece) => scorePiece(piece, profile, totals));
$("#totalDamage").textContent = fmt(totals.baseDamage);
@@ -169,7 +170,7 @@ function updateAnalysis() {
});
updateEffectImpactHints(totals, dps);
renderEffectTotals(totals.effects);
renderEffectTotals(totals, dps, survivability);
renderUpgrades(profile, totals, dps);
renderSacrifices(pieceScores);
saveDraft();
@@ -202,6 +203,16 @@ function calculateDps(totals, combatStyle = "melee") {
return baseDamage * globalDamage * styleDamage * attackSpeed * doubleHit * crit * cooldown;
}
function calculateSurvivability(totals) {
const effects = totals.effects;
const baseHealth = Math.max(0, totals.baseHealth);
const health = baseHealth * (1 + effects.health / 100);
const blockMultiplier = 1 / Math.max(0.05, 1 - effects.blockChance / 100);
const regenMultiplier = 1 + effects.healthRegen / 100;
const lifestealMultiplier = 1 + effects.lifesteal / 100;
return health * blockMultiplier * regenMultiplier * lifestealMultiplier;
}
function getStyleDamageBonus(effects, combatStyle) {
if (combatStyle === "ranged") return effects.rangedDamage;
if (combatStyle === "skill") return effects.skillDamage;
@@ -219,6 +230,16 @@ function cloneTotalsWithEffectDelta(totals, effectType, delta) {
};
}
function describeMaxRollGain(effect, totals, currentDps, currentSurvivability) {
const withMaxRoll = cloneTotalsWithEffectDelta(totals, effect.id, effect.cap);
const dpsGain = percentChange(currentDps, calculateDps(withMaxRoll, state.combatStyle));
const survivabilityGain = percentChange(currentSurvivability, calculateSurvivability(withMaxRoll));
const parts = [];
if (Math.abs(dpsGain) >= 0.05) parts.push(`+${fmt(dpsGain)}% DPS`);
if (Math.abs(survivabilityGain) >= 0.05) parts.push(`+${fmt(survivabilityGain)}% survivability`);
return parts.length ? parts.join(" / ") : "no effect for current style";
}
function percentChange(from, to) {
if (from <= 0) return to > 0 ? 100 : 0;
return ((to / from) - 1) * 100;
@@ -253,9 +274,13 @@ function scorePiece(piece, profile, totals) {
return { piece, score, reasons: [...new Set(reasons)] };
}
function renderEffectTotals(effectTotals) {
function renderEffectTotals(totals, currentDps, currentSurvivability) {
$("#effectTotals").innerHTML = EFFECTS.map((effect) => `
<div class="effect-pill"><span>${effect.label}</span><strong>${fmt(effectTotals[effect.id])}%</strong></div>
<div class="effect-pill">
<span>${effect.label}</span>
<strong>${fmt(totals.effects[effect.id])}%</strong>
<small>Max roll +${effect.cap}%: ${describeMaxRollGain(effect, totals, currentDps, currentSurvivability)}</small>
</div>
`).join("");
}