Show current effect averages in damage optimizer
This commit is contained in:
@@ -673,6 +673,18 @@ function countActiveEffects() {
|
|||||||
return state.pieces.reduce((count, piece) => count + (piece.effects || []).filter((effect) => effect.type).length, 0);
|
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() {
|
function createEmptyEffectTotals() {
|
||||||
return Object.fromEntries(EFFECTS.map((effect) => [effect.id, 0]));
|
return Object.fromEntries(EFFECTS.map((effect) => [effect.id, 0]));
|
||||||
}
|
}
|
||||||
@@ -715,10 +727,21 @@ function formatOptimalSuggestion(counts) {
|
|||||||
.join(", ");
|
.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) {
|
function renderOptimalDamageSetup(totals, currentDps) {
|
||||||
const effectCount = countActiveEffects();
|
const effectCount = countActiveEffects();
|
||||||
const optimum = findOptimalDamageSetup(totals, effectCount, state.combatStyle);
|
const optimum = findOptimalDamageSetup(totals, effectCount, state.combatStyle);
|
||||||
const delta = percentChange(currentDps, optimum.dps);
|
const delta = percentChange(currentDps, optimum.dps);
|
||||||
|
const currentEffectSummary = summarizeCurrentEffects();
|
||||||
|
|
||||||
$("#optimumEffectCount").textContent = `${effectCount} effect${effectCount === 1 ? "" : "s"}`;
|
$("#optimumEffectCount").textContent = `${effectCount} effect${effectCount === 1 ? "" : "s"}`;
|
||||||
$("#optimumDps").textContent = fmt(optimum.dps);
|
$("#optimumDps").textContent = fmt(optimum.dps);
|
||||||
@@ -727,6 +750,9 @@ function renderOptimalDamageSetup(totals, currentDps) {
|
|||||||
$("#optimumSuggestion").textContent = effectCount
|
$("#optimumSuggestion").textContent = effectCount
|
||||||
? formatOptimalSuggestion(optimum.counts)
|
? formatOptimalSuggestion(optimum.counts)
|
||||||
: "Add effects to your current build to see an optimized max-roll damage mix.";
|
: "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) {
|
function updateEffectImpactHints(totals, currentDps) {
|
||||||
|
|||||||
@@ -100,6 +100,10 @@
|
|||||||
<div><span>Difference vs current</span><strong id="optimumDpsDelta">0</strong></div>
|
<div><span>Difference vs current</span><strong id="optimumDpsDelta">0</strong></div>
|
||||||
</div>
|
</div>
|
||||||
<p id="optimumSuggestion" class="optimum-suggestion"></p>
|
<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>
|
||||||
|
|
||||||
<section class="card new-item-card" aria-labelledby="new-item-heading">
|
<section class="card new-item-card" aria-labelledby="new-item-heading">
|
||||||
|
|||||||
+10
@@ -284,6 +284,16 @@ h3 { margin-bottom: 0; }
|
|||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
overflow-wrap: anywhere;
|
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 {
|
.swap-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
Reference in New Issue
Block a user