Clarify new item swap naming
This commit is contained in:
@@ -346,8 +346,8 @@ function updateAnalysis() {
|
||||
}
|
||||
|
||||
function renderReplacementComparison(totals, currentDps, currentRegen, pieceScores) {
|
||||
const { targetPiece, candidate } = getReplacementContext(pieceScores);
|
||||
const replacementTotals = replacePieceInTotals(totals, targetPiece, candidate);
|
||||
const { targetPiece, newItemPiece } = getReplacementContext(pieceScores);
|
||||
const replacementTotals = replacePieceInTotals(totals, targetPiece, newItemPiece);
|
||||
const replacementDps = calculateDps(replacementTotals, state.combatStyle);
|
||||
const replacementRegen = calculateRegenDetails(replacementTotals, replacementDps).total;
|
||||
const dpsDelta = percentChange(currentDps, replacementDps);
|
||||
@@ -426,7 +426,7 @@ function getReplacementContext(pieceScores) {
|
||||
target,
|
||||
targetPiece,
|
||||
targetIndex: targetPiece ? state.pieces.indexOf(targetPiece) : -1,
|
||||
candidate: createNewItemCandidate(target),
|
||||
newItemPiece: createNewItemCandidate(target),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -459,9 +459,9 @@ function createNewItemCandidate(target) {
|
||||
};
|
||||
}
|
||||
|
||||
function createPieceFromCandidate(existingPiece, candidate) {
|
||||
const baseDamage = Number(candidate.baseDamage || 0);
|
||||
const baseHealth = Number(candidate.baseHealth || 0);
|
||||
function createPieceFromCandidate(existingPiece, newItemPiece) {
|
||||
const baseDamage = Number(newItemPiece.baseDamage || 0);
|
||||
const baseHealth = Number(newItemPiece.baseHealth || 0);
|
||||
return enforceFixedPieceFields({
|
||||
...existingPiece,
|
||||
baseDamage,
|
||||
@@ -470,7 +470,7 @@ function createPieceFromCandidate(existingPiece, candidate) {
|
||||
baseValue: existingPiece.fixedBase
|
||||
? (existingPiece.baseType === "health" ? baseHealth : baseDamage)
|
||||
: Math.max(baseDamage, baseHealth),
|
||||
effects: candidate.effects.map((effect) => ({ ...effect })),
|
||||
effects: newItemPiece.effects.map((effect) => ({ ...effect })),
|
||||
}, state.pieces.indexOf(existingPiece));
|
||||
}
|
||||
|
||||
@@ -492,12 +492,12 @@ function swapInNewItem() {
|
||||
const profile = PROFILES[state.profile];
|
||||
const totals = calculateTotals();
|
||||
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;
|
||||
const previousPiece = clonePiece(targetPiece);
|
||||
const previousNewItem = cloneNewItem(state.newItem);
|
||||
state.pieces[targetIndex] = createPieceFromCandidate(targetPiece, candidate);
|
||||
state.newItem = createNewItemFromPiece(previousPiece, previousNewItem.target, targetPiece.id);
|
||||
const swappedOutPiece = clonePiece(targetPiece);
|
||||
const previousNewItemState = cloneNewItem(state.newItem);
|
||||
state.pieces[targetIndex] = createPieceFromCandidate(targetPiece, newItemPiece);
|
||||
state.newItem = createNewItemFromPiece(swappedOutPiece, previousNewItemState.target, targetPiece.id);
|
||||
render();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user