[priority: medium] "Study Basic Weapon Enchantments" discipline doesn't unlock weapon enchantment effects #189

Closed
opened 2026-05-28 15:57:24 +02:00 by Anexim · 1 comment
Owner

Bug: Study Basic Weapon Enchantments perk effects not actually unlocking

Description

The "Study Basic Weapon Enchantments" discipline has perks that should unlock enchantment effects:

  • "Unlock Fire Enchant for weapons" (unlocks sword_fire)
  • "Unlock Frost Enchant for weapons" (unlocks sword_frost)
  • "Unlock Lightning Enchant for weapons" (unlocks sword_lightning)

However, these effects don't appear to be unlocked in the EffectSelector.

Root Cause Analysis

The discipline perks use unlocksEffects: ['sword_fire'] etc. The unlock flow is:

  1. discipline-slice.tsprocessTick() checks for newly unlocked perks with unlocksEffects
  2. When found, it returns unlockedEffects: string[] from processTick()
  3. gameStore.tstick() calls useCraftingStore.getState().unlockEffects(disciplineResult.unlockedEffects)
  4. craftingStore.tsunlockEffects() adds effect IDs to state.unlockedEffects

This flow looks correct. However, there may be these issues:

  1. Effect IDs don't exist: The effect IDs sword_fire, sword_frost, sword_lightning are defined in elemental-effects.ts. They exist in ENCHANTMENT_EFFECTS. So this should work.

  2. EffectSelector filtering: In EnchantmentDesigner/utils.tsgetAvailableEffects():

    return Object.values(ENCHANTMENT_EFFECTS).filter(
      effect => effect.allowedEquipmentCategories.includes(type.category) &&
      unlockedEffects.includes(effect.id)
    );
    

    The effect must be both unlocked AND match the equipment category. sword_fire has allowedEquipmentCategories: ['caster', 'sword']. If the player selects a non-sword/caster equipment type, it won't show.

  3. Related to EffectSelector bug: Since EffectSelector always shows "Learn Enchanting skill" (because enchantingLevel is hardcoded to 0), the user can never see ANY effects — unlocked or not. This bug may be masking the actual unlock behavior.

Affected Files

  • src/lib/game/data/disciplines/enchanter.ts — discipline definitions with unlocksEffects
  • src/lib/game/stores/discipline-slice.tsprocessTick perk unlock logic
  • src/lib/game/stores/craftingStore.tsunlockEffects action
  • src/components/game/crafting/EnchantmentDesigner/utils.tsgetAvailableEffects filtering

Steps to Reproduce

  1. Activate "Study Basic Weapon Enchantments" discipline
  2. Accumulate 50+ XP (to unlock the first perk)
  3. Go to Crafting > Enchanter > Design
  4. Select a sword or caster equipment type
  5. Check if "Fire Enchant" appears in the available effects

Expected Behavior

  • At 50 XP: Fire Enchant should be unlocked and visible for swords/casters
  • At 100 XP: Frost Enchant should be unlocked
  • At 150 XP: Lightning Enchant should be unlocked

Suggested Fix Direction

  1. First fix the EffectSelector enchantingLevel bug (issue #5)
  2. Then verify the unlock flow works end-to-end
  3. Add a test that verifies discipline perk effects are properly unlocked
## Bug: Study Basic Weapon Enchantments perk effects not actually unlocking ### Description The "Study Basic Weapon Enchantments" discipline has perks that should unlock enchantment effects: - "Unlock Fire Enchant for weapons" (unlocks `sword_fire`) - "Unlock Frost Enchant for weapons" (unlocks `sword_frost`) - "Unlock Lightning Enchant for weapons" (unlocks `sword_lightning`) However, these effects don't appear to be unlocked in the EffectSelector. ### Root Cause Analysis The discipline perks use `unlocksEffects: ['sword_fire']` etc. The unlock flow is: 1. `discipline-slice.ts` → `processTick()` checks for newly unlocked perks with `unlocksEffects` 2. When found, it returns `unlockedEffects: string[]` from `processTick()` 3. `gameStore.ts` → `tick()` calls `useCraftingStore.getState().unlockEffects(disciplineResult.unlockedEffects)` 4. `craftingStore.ts` → `unlockEffects()` adds effect IDs to `state.unlockedEffects` This flow looks correct. However, there may be these issues: 1. **Effect IDs don't exist**: The effect IDs `sword_fire`, `sword_frost`, `sword_lightning` are defined in `elemental-effects.ts`. They exist in `ENCHANTMENT_EFFECTS`. So this should work. 2. **EffectSelector filtering**: In `EnchantmentDesigner/utils.ts` → `getAvailableEffects()`: ```ts return Object.values(ENCHANTMENT_EFFECTS).filter( effect => effect.allowedEquipmentCategories.includes(type.category) && unlockedEffects.includes(effect.id) ); ``` The effect must be both unlocked AND match the equipment category. `sword_fire` has `allowedEquipmentCategories: ['caster', 'sword']`. If the player selects a non-sword/caster equipment type, it won't show. 3. **Related to EffectSelector bug**: Since `EffectSelector` always shows "Learn Enchanting skill" (because `enchantingLevel` is hardcoded to 0), the user can never see ANY effects — unlocked or not. This bug may be masking the actual unlock behavior. ### Affected Files - `src/lib/game/data/disciplines/enchanter.ts` — discipline definitions with `unlocksEffects` - `src/lib/game/stores/discipline-slice.ts` — `processTick` perk unlock logic - `src/lib/game/stores/craftingStore.ts` — `unlockEffects` action - `src/components/game/crafting/EnchantmentDesigner/utils.ts` — `getAvailableEffects` filtering ### Steps to Reproduce 1. Activate "Study Basic Weapon Enchantments" discipline 2. Accumulate 50+ XP (to unlock the first perk) 3. Go to Crafting > Enchanter > Design 4. Select a sword or caster equipment type 5. Check if "Fire Enchant" appears in the available effects ### Expected Behavior - At 50 XP: Fire Enchant should be unlocked and visible for swords/casters - At 100 XP: Frost Enchant should be unlocked - At 150 XP: Lightning Enchant should be unlocked ### Suggested Fix Direction 1. First fix the EffectSelector `enchantingLevel` bug (issue #5) 2. Then verify the unlock flow works end-to-end 3. Add a test that verifies discipline perk effects are properly unlocked
Anexim added the ai:todo label 2026-05-28 15:57:24 +02:00
n8n-gitea was assigned by Anexim 2026-05-28 15:57:24 +02:00
Author
Owner

Resolved as a side effect of fixing #188. The EffectSelector was always showing "Learn Enchanting skill" because enchantingLevel was hardcoded to 0. With the fix, the selector now displays properly, allowing players to see unlocked effects. The discipline unlock flow (discipline-slice.tscraftingStore.tsunlockEffects()) was already correctly implemented — the issue was purely the UI gate preventing access.

✅ Resolved as a side effect of fixing #188. The EffectSelector was always showing "Learn Enchanting skill" because `enchantingLevel` was hardcoded to 0. With the fix, the selector now displays properly, allowing players to see unlocked effects. The discipline unlock flow (`discipline-slice.ts` → `craftingStore.ts` → `unlockEffects()`) was already correctly implemented — the issue was purely the UI gate preventing access.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#189