Clarify new item swap naming

This commit is contained in:
Jan Bader
2026-06-17 22:35:13 +02:00
parent 84959d2e8b
commit 3975acd87d
+12 -12
View File
@@ -346,8 +346,8 @@ function updateAnalysis() {
} }
function renderReplacementComparison(totals, currentDps, currentRegen, pieceScores) { function renderReplacementComparison(totals, currentDps, currentRegen, pieceScores) {
const { targetPiece, candidate } = getReplacementContext(pieceScores); const { targetPiece, newItemPiece } = getReplacementContext(pieceScores);
const replacementTotals = replacePieceInTotals(totals, targetPiece, candidate); const replacementTotals = replacePieceInTotals(totals, targetPiece, newItemPiece);
const replacementDps = calculateDps(replacementTotals, state.combatStyle); const replacementDps = calculateDps(replacementTotals, state.combatStyle);
const replacementRegen = calculateRegenDetails(replacementTotals, replacementDps).total; const replacementRegen = calculateRegenDetails(replacementTotals, replacementDps).total;
const dpsDelta = percentChange(currentDps, replacementDps); const dpsDelta = percentChange(currentDps, replacementDps);
@@ -426,7 +426,7 @@ function getReplacementContext(pieceScores) {
target, target,
targetPiece, targetPiece,
targetIndex: targetPiece ? state.pieces.indexOf(targetPiece) : -1, targetIndex: targetPiece ? state.pieces.indexOf(targetPiece) : -1,
candidate: createNewItemCandidate(target), newItemPiece: createNewItemCandidate(target),
}; };
} }
@@ -459,9 +459,9 @@ function createNewItemCandidate(target) {
}; };
} }
function createPieceFromCandidate(existingPiece, candidate) { function createPieceFromCandidate(existingPiece, newItemPiece) {
const baseDamage = Number(candidate.baseDamage || 0); const baseDamage = Number(newItemPiece.baseDamage || 0);
const baseHealth = Number(candidate.baseHealth || 0); const baseHealth = Number(newItemPiece.baseHealth || 0);
return enforceFixedPieceFields({ return enforceFixedPieceFields({
...existingPiece, ...existingPiece,
baseDamage, baseDamage,
@@ -470,7 +470,7 @@ function createPieceFromCandidate(existingPiece, candidate) {
baseValue: existingPiece.fixedBase baseValue: existingPiece.fixedBase
? (existingPiece.baseType === "health" ? baseHealth : baseDamage) ? (existingPiece.baseType === "health" ? baseHealth : baseDamage)
: Math.max(baseDamage, baseHealth), : Math.max(baseDamage, baseHealth),
effects: candidate.effects.map((effect) => ({ ...effect })), effects: newItemPiece.effects.map((effect) => ({ ...effect })),
}, state.pieces.indexOf(existingPiece)); }, state.pieces.indexOf(existingPiece));
} }
@@ -492,12 +492,12 @@ function swapInNewItem() {
const profile = PROFILES[state.profile]; const profile = PROFILES[state.profile];
const totals = calculateTotals(); const totals = calculateTotals();
const pieceScores = state.pieces.map((piece) => scorePiece(piece, profile, totals)); const pieceScores = state.pieces.map((piece) => scorePiece(piece, profile, totals));
const { targetPiece, targetIndex, candidate } = getReplacementContext(pieceScores); const { targetPiece, targetIndex, newItemPiece } = getReplacementContext(pieceScores);
if (!targetPiece || targetIndex < 0) return; if (!targetPiece || targetIndex < 0) return;
const previousPiece = clonePiece(targetPiece); const swappedOutPiece = clonePiece(targetPiece);
const previousNewItem = cloneNewItem(state.newItem); const previousNewItemState = cloneNewItem(state.newItem);
state.pieces[targetIndex] = createPieceFromCandidate(targetPiece, candidate); state.pieces[targetIndex] = createPieceFromCandidate(targetPiece, newItemPiece);
state.newItem = createNewItemFromPiece(previousPiece, previousNewItem.target, targetPiece.id); state.newItem = createNewItemFromPiece(swappedOutPiece, previousNewItemState.target, targetPiece.id);
render(); render();
} }