[High] [Bug] Crystal conversion sand cost halved due to duplicate key in recipe #359
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?
Severity: High
File:
src/lib/game/data/conversion-costs.ts(line 107)Description:
The crystal conversion recipe is defined as:
When
Object.fromEntries(components.map(c => [c, computeComponentCost(3)]))is called, the duplicatesandkey means the second entry overwrites the first. The resulting component cost for sand is40instead of the intended80.Impact: Exploit — crystal conversion costs only 40 sand per unit instead of the intended 80, making crystal mana cheaper to produce than designed. This breaks the game's mana economy balance.
Fix needed: Change the recipe to
['sand', 'light']with a higher per-unit cost, or change the cost computation to properly handle duplicate components by summing them.Starting work on fixing the Crystal conversion duplicate key bug. Investigating conversion-costs.ts for the duplicate key issue.
Fixed. Changed compositeElementCost, exoticElementCost, and timeElementCost to use a manual loop that sums costs for duplicate component keys instead of Object.fromEntries which silently overwrites duplicates. Crystal now correctly costs 80 sand (40×2) + 40 light. All 1157 tests pass.