Show current effect averages in damage optimizer

This commit is contained in:
Jan Bader
2026-06-20 23:53:39 +02:00
parent 196e6e3630
commit 8a3c703961
3 changed files with 40 additions and 0 deletions
+26
View File
@@ -673,6 +673,18 @@ function countActiveEffects() {
return state.pieces.reduce((count, piece) => count + (piece.effects || []).filter((effect) => effect.type).length, 0);
}
function summarizeCurrentEffects() {
const summary = Object.fromEntries(EFFECTS.map((effect) => [effect.id, { count: 0, total: 0 }]));
for (const piece of state.pieces) {
for (const effect of piece.effects || []) {
if (!effect.type) continue;
summary[effect.type].count += 1;
summary[effect.type].total += clampEffectValue(effect.type, Number(effect.value));
}
}
return summary;
}
function createEmptyEffectTotals() {
return Object.fromEntries(EFFECTS.map((effect) => [effect.id, 0]));
}
@@ -715,10 +727,21 @@ function formatOptimalSuggestion(counts) {
.join(", ");
}
function formatCurrentEffectAverages(summary) {
return Object.entries(summary)
.filter(([, data]) => data.count > 0)
.map(([effectId, data]) => {
const effect = effectById(effectId);
return `${data.count}x avg ${fmt(data.total / data.count)}% ${effect.label.toLowerCase()}`;
})
.join(", ");
}
function renderOptimalDamageSetup(totals, currentDps) {
const effectCount = countActiveEffects();
const optimum = findOptimalDamageSetup(totals, effectCount, state.combatStyle);
const delta = percentChange(currentDps, optimum.dps);
const currentEffectSummary = summarizeCurrentEffects();
$("#optimumEffectCount").textContent = `${effectCount} effect${effectCount === 1 ? "" : "s"}`;
$("#optimumDps").textContent = fmt(optimum.dps);
@@ -727,6 +750,9 @@ function renderOptimalDamageSetup(totals, currentDps) {
$("#optimumSuggestion").textContent = effectCount
? formatOptimalSuggestion(optimum.counts)
: "Add effects to your current build to see an optimized max-roll damage mix.";
$("#currentEffectAverages").textContent = effectCount
? formatCurrentEffectAverages(currentEffectSummary)
: "No current effects entered.";
}
function updateEffectImpactHints(totals, currentDps) {
+4
View File
@@ -100,6 +100,10 @@
<div><span>Difference vs current</span><strong id="optimumDpsDelta">0</strong></div>
</div>
<p id="optimumSuggestion" class="optimum-suggestion"></p>
<div class="current-effect-summary">
<h3>Current effects</h3>
<p id="currentEffectAverages" class="optimum-suggestion"></p>
</div>
</section>
<section class="card new-item-card" aria-labelledby="new-item-heading">
+10
View File
@@ -284,6 +284,16 @@ h3 { margin-bottom: 0; }
font-weight: 800;
overflow-wrap: anywhere;
}
.current-effect-summary {
border-top: 1px solid var(--border);
padding-top: 0.75rem;
}
.current-effect-summary h3 {
color: var(--muted);
font-size: 0.95rem;
margin-bottom: 0.35rem;
}
.current-effect-summary .optimum-suggestion { color: var(--text); }
.swap-actions {
display: flex;
flex-wrap: wrap;