[High] [Bug] Item Fabrication: Crafting Efficiency cost reduction never applied #316

Closed
opened 2026-06-07 17:43:57 +02:00 by Anexim · 3 comments
Owner

Spec: docs/specs/attunements/fabricator/systems/item-fabrication-spec.md §7
Severity: Missing feature

Problem: The craftingCostReduction stat is correctly defined in the discipline (base 15 + perk 10 = 25% max), but no code in any crafting path reads or applies it:

  • src/lib/game/crafting-fabricator.ts:141-148deductMaterials() deducts full recipe amounts
  • src/lib/game/stores/pipelines/equipment-crafting.ts:120-132 — uses raw recipe amounts
  • UI components check against raw amounts

The entire Crafting Efficiency cost reduction mechanic is non-functional.

Files: src/lib/game/crafting-fabricator.ts:141-148, src/lib/game/stores/pipelines/equipment-crafting.ts:120-132

**Spec:** docs/specs/attunements/fabricator/systems/item-fabrication-spec.md §7 **Severity:** Missing feature **Problem:** The `craftingCostReduction` stat is correctly defined in the discipline (base 15 + perk 10 = 25% max), but **no code in any crafting path reads or applies it**: - `src/lib/game/crafting-fabricator.ts:141-148` — `deductMaterials()` deducts full recipe amounts - `src/lib/game/stores/pipelines/equipment-crafting.ts:120-132` — uses raw recipe amounts - UI components check against raw amounts The entire Crafting Efficiency cost reduction mechanic is non-functional. **Files:** `src/lib/game/crafting-fabricator.ts:141-148`, `src/lib/game/stores/pipelines/equipment-crafting.ts:120-132`
Anexim added the ai:todo label 2026-06-07 17:43:57 +02:00
n8n-gitea was assigned by Anexim 2026-06-07 17:43:57 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-07 23:07:46 +02:00
Author
Owner

Starting work on this bug. Investigating Item Fabrication Crafting Efficiency cost reduction issue.

Starting work on this bug. Investigating Item Fabrication Crafting Efficiency cost reduction issue.
Author
Owner

Fix implemented and tested.

Root cause: The craftingCostReduction stat was correctly computed by computeDisciplineEffects() but never consumed by any crafting code path. Material deductions, cost checks, and UI displays all used raw recipe amounts.

Changes made across 5 files:

  1. src/lib/game/crafting-fabricator.ts — Added getCraftingCostReduction() helper (reads from discipline effects bonuses, capped at 75%). Added applyCostReduction(baseAmount, reduction) helper. Modified deductMaterials() and checkFabricatorCosts() to accept optional costReduction param (defaults to live discipline value). executeMaterialCraft() benefits automatically since it calls deductMaterials().

  2. src/lib/game/stores/pipelines/equipment-crafting.tsstartFabricatorCrafting() passes cost reduction through to deductMaterials(). cancelEquipmentCrafting() now uses reduced amounts for material refunds (player only gets back what they actually paid).

  3. src/lib/game/data/fabricator-recipes.tscanCraftRecipe() now accepts optional costReduction param and checks against discounted amounts.

  4. src/components/game/tabs/CraftingTab/FabricatorSubTab.tsxRecipeCard and MaterialRecipeCard receive costReduction prop from parent. UI shows discounted costs with original cost in parenthetical. Shows -% cost badge when reduction is active.

  5. src/components/game/tabs/CraftingTab/MaterialRecipeCard.tsx — Added costReduction prop, applies to material display and canCraftRecipe check.

Formula (per spec §7): actualCost = ceil(baseCost × (1 - craftingCostReduction / 100)), minimum 1.

Verification:

  • All 52 test files / 1009 tests pass
  • No new TypeScript errors introduced
  • All modified files under 400-line limit
  • No circular dependency introduced
**Fix implemented and tested.** **Root cause:** The `craftingCostReduction` stat was correctly computed by `computeDisciplineEffects()` but never consumed by any crafting code path. Material deductions, cost checks, and UI displays all used raw recipe amounts. **Changes made across 5 files:** 1. **`src/lib/game/crafting-fabricator.ts`** — Added `getCraftingCostReduction()` helper (reads from discipline effects bonuses, capped at 75%). Added `applyCostReduction(baseAmount, reduction)` helper. Modified `deductMaterials()` and `checkFabricatorCosts()` to accept optional `costReduction` param (defaults to live discipline value). `executeMaterialCraft()` benefits automatically since it calls `deductMaterials()`. 2. **`src/lib/game/stores/pipelines/equipment-crafting.ts`** — `startFabricatorCrafting()` passes cost reduction through to `deductMaterials()`. `cancelEquipmentCrafting()` now uses reduced amounts for material refunds (player only gets back what they actually paid). 3. **`src/lib/game/data/fabricator-recipes.ts`** — `canCraftRecipe()` now accepts optional `costReduction` param and checks against discounted amounts. 4. **`src/components/game/tabs/CraftingTab/FabricatorSubTab.tsx`** — `RecipeCard` and `MaterialRecipeCard` receive `costReduction` prop from parent. UI shows discounted costs with original cost in parenthetical. Shows `-% cost` badge when reduction is active. 5. **`src/components/game/tabs/CraftingTab/MaterialRecipeCard.tsx`** — Added `costReduction` prop, applies to material display and `canCraftRecipe` check. **Formula (per spec §7):** `actualCost = ceil(baseCost × (1 - craftingCostReduction / 100))`, minimum 1. **Verification:** - All 52 test files / 1009 tests pass ✅ - No new TypeScript errors introduced ✅ - All modified files under 400-line limit ✅ - No circular dependency introduced ✅
Anexim added ai:done and removed ai:in-progress labels 2026-06-07 23:15:18 +02:00
Author
Owner

Fix complete. All tests passing. Ready for review.

Fix complete. All tests passing. Ready for review.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#316