Feature 17: Gear Enhancement & Reforging
Overview
Endgame item progression: enhancement (+1 to +5 upgrades that increase base stats) and reforging (re-roll random bonus properties on Rare+ items). Both are material and gold sinks that give max-level players long-term goals without adding power creep.
Dependencies
- Feature 03 (Items & Inventory) — gear with bonus properties
- Feature 08 (Crafting) — crafting materials used as enhancement/reforge inputs
- Feature 09 (Economy) — gold sinks
Technical Tasks
1. Enhancement Logic (crates/game)
- Create
src/enhancement.rs:- Enhancement levels: +1 through +5
- Per level: material cost, gold cost, success chance
- +1: 5 Uncommon Shards, 500 gold, 100% success
- +2: 10 Uncommon Shards + 2 Rare Cores, 2000 gold, 80% success
- +3: 5 Rare Cores, 5000 gold, 60% success
- +4: 10 Rare Cores + 2 Prismatic Essences, 15000 gold, 40% success
- +5: 5 Prismatic Essences + 1 Legendary Spark, 50000 gold, 20% success
- Failure: item stays at current level (no downgrade), materials consumed
enhance_item(item: &Item, target_level: u8, rng: &mut impl Rng) -> EnhanceResult:- Check current enhancement < target
- Roll success chance
- Return Success(new_level) or Failure(current_level)
enhancement_stat_bonus(base_stat: u16, level: u8) -> u16:- +5% per level to base damage/armor/evasion
2. Reforging Logic (crates/game)
- Create
src/reforging.rs:- Only available for Rare+ items (they have random bonus properties)
reforge_cost(rarity: Rarity) -> ReforgeCost:- Rare: 3 Rare Cores + 1000 gold
- Very Rare: 5 Rare Cores + 2 Prismatic Essences + 5000 gold
- Legendary: 3 Prismatic Essences + 1 Legendary Spark + 20000 gold
reforge_item(item: &mut Item, rng: &mut impl Rng) -> Vec<BonusProperty>:- Re-roll ALL random bonus properties (keep count, re-roll values and types)
- Signature effect is NOT re-rolled (it’s fixed per template)
- Return new bonus properties
3. API Routes (crates/api)
- Add to
src/routes/inventory.rs:POST /api/characters/:id/enhance:- Body:
{ item_id } - Validate: item owned, enhancement < 5, has materials + gold
- Deduct materials and gold
- Roll enhancement
- Return
{ success, new_enhancement_level }
- Body:
POST /api/characters/:id/reforge:- Body:
{ item_id } - Validate: item owned, Rare+ rarity, has materials + gold
- Deduct materials and gold
- Re-roll bonuses
- Return
{ new_bonus_properties }
- Body:
4. Client — Enhancement & Reforging UI
- Add to inventory screen:
- “Enhance” button on eligible items → modal showing cost, success chance, current level
- “Reforge” button on Rare+ items → modal showing cost, current bonuses, warning about random results
- Enhancement level displayed on item: “+3 Iron Longsword”
- Visual indicator of enhancement level (glow effect or badge)
Tests
Unit Tests
enhance_item: +1 always succeeds (100%)enhance_item: +5 has 20% success rate (statistical test with seeded RNG)enhance_item: failure doesn’t downgradeenhancement_stat_bonus: +5 at level 3 = +15% bonusreforge_item: keeps same number of bonus propertiesreforge_item: can produce different properties than originalreforge_item: deterministic with seeded RNGreforge_cost: correct per rarity tier
Integration Tests
POST /api/characters/:id/enhancededucts materials and goldPOST /api/characters/:id/enhanceon max (+5) → 409POST /api/characters/:id/enhancewith insufficient materials → 422POST /api/characters/:id/reforgere-rolls bonuses, deducts costPOST /api/characters/:id/reforgeon Common item → 422- Enhanced item stats correctly increased in equipment calculations