Bug: Equipment crafting cancellation gives flat 50% refund regardless of progress #216

Closed
opened 2026-05-30 19:46:58 +02:00 by Anexim · 1 comment
Owner

Bug Description

When cancelling equipment crafting, the player receives a flat 50% refund of the total mana cost, regardless of how much progress has been made. This means cancelling at 99% completion still refunds 50% of the full cost.

Code Location

  • src/lib/game/crafting-equipment.ts lines 125-130: cancelEquipmentCrafting uses manaSpent (total recipe cost) for the refund calculation
  • src/lib/game/stores/craftingStore.ts lines 208-215: cancelEquipmentCrafting action passes progress.manaSpent (total cost, not remaining)
const manaRefund = Math.floor(manaSpent * MANA_REFUND_RATE);

Impact

Players can exploit this by:

  1. Starting expensive crafts
  2. Letting them progress almost to completion
  3. Cancelling for a flat 50% refund
  4. Repeating to effectively get a 50% discount on all crafting

Fix Required

The refund should be proportional to remaining progress:

const remainingRatio = 1 - (progress.currentProgress / progress.required);
const manaRefund = Math.floor(manaSpent * remainingRatio * MANA_REFUND_RATE);

Or alternatively, track manaAlreadySpent separately from manaRemaining and refund based on remaining.

## Bug Description When cancelling equipment crafting, the player receives a flat 50% refund of the **total** mana cost, regardless of how much progress has been made. This means cancelling at 99% completion still refunds 50% of the full cost. ## Code Location - `src/lib/game/crafting-equipment.ts` lines 125-130: `cancelEquipmentCrafting` uses `manaSpent` (total recipe cost) for the refund calculation - `src/lib/game/stores/craftingStore.ts` lines 208-215: `cancelEquipmentCrafting` action passes `progress.manaSpent` (total cost, not remaining) ```typescript const manaRefund = Math.floor(manaSpent * MANA_REFUND_RATE); ``` ## Impact Players can exploit this by: 1. Starting expensive crafts 2. Letting them progress almost to completion 3. Cancelling for a flat 50% refund 4. Repeating to effectively get a 50% discount on all crafting ## Fix Required The refund should be proportional to remaining progress: ```typescript const remainingRatio = 1 - (progress.currentProgress / progress.required); const manaRefund = Math.floor(manaSpent * remainingRatio * MANA_REFUND_RATE); ``` Or alternatively, track `manaAlreadySpent` separately from `manaRemaining` and refund based on remaining.
Anexim added the ai:todo label 2026-05-30 19:46:58 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 19:46:58 +02:00
Author
Owner

Fixed: Equipment crafting cancellation now refunds proportionally to remaining progress instead of a flat 50%. Also added material refund on cancellation in craftingStore.ts. The refund rate is: full refund for unspent progress + 50% for spent progress.

Fixed: Equipment crafting cancellation now refunds proportionally to remaining progress instead of a flat 50%. Also added material refund on cancellation in craftingStore.ts. The refund rate is: full refund for unspent progress + 50% for spent progress.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#216