[Medium] [Bug] Item Fabrication: Material cancellation refund uses wrong formula #317
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec: docs/specs/attunements/fabricator/systems/item-fabrication-spec.md §6.3
Severity: Wrong formula
Problem: The spec says material refund should be a flat 50% regardless of progress. The code in
src/lib/game/stores/pipelines/equipment-crafting.ts:89-94,107-113usesremainingFractionfor materials:This means:
File:
src/lib/game/stores/pipelines/equipment-crafting.ts:89-94,107-113Starting investigation. Reading spec §6.3 and the buggy file equipment-crafting.ts.
Root cause confirmed.
Spec §6.3 states:
refundRate = remainingFraction + (1 - remainingFraction) × 0.5(blended rate)floor(materialsSpent × 0.5)(flat 50%)Both the fabricator branch (line 89-94) and standard equipment branch (line 107-113) incorrectly use
remainingFractionfor material refunds instead of flat0.5.Fixing both branches to use
0.5for material refunds.Fixed. Changed material refund in both branches of
cancelEquipmentCrafting()inequipment-crafting.ts:Math.floor(reducedAmount * remainingFraction)→Math.floor(reducedAmount * 0.5)Math.floor(amount * remainingFraction)→Math.floor(amount * 0.5)Also cleaned up the now-unnecessary
remainingFractionvariable and its associated lines in the standard equipment branch. The mana refund formula (refundRate = remainingFraction + (1 - remainingFraction) * 0.5) was already correct and left unchanged.All 1060 tests pass. Pre-commit hooks pass.