[priority: highest] fix: Discipline perk numerical bonuses are dead code — once/infinite/capped perks don't apply #137
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?
Problem
Discipline perks (
once,infinite,capped) fire and their IDs are added to aspecialsset incomputeDisciplineEffects(), but nothing in the game engine reads those IDs back out to apply numerical bonuses. The perk descriptions document bonuses (e.g. "+50 Max Mana", "Every 100 XP: +25 Max Mana") that never actually affect any game stat.Additionally,
perk.unlocksEffectsis defined on ~40 enchantment-study perks but the field is never read anywhere — effects are only unlocked through a separate path indiscipline-slice.ts processTick().Root Cause
In
src/lib/game/effects/discipline-effects.ts:once/infiniteperks →specials.add(perk.id)— but no code checks for discipline perk IDs in the specials set. OnlySPECIAL_EFFECTS.*enum values (likeMANA_CASCADE,ENCH_MASTERY) are consumed.cappedperks →multipliers['perk_enchant-2']— butcomputeAllEffects()only reads known keys likemaxMana,regen,baseDamage, etc. Namespacedperk_*keys are never consumed.unlocksEffectson perks — dead field. Effect unlocking happens indiscipline-slice.tsviaprocessedPerkstracking, not through this field.Perk Data Issues
Most
onceperks havevalue: 0with the bonus amount only in thedescriptionstring. Mostinfiniteperks encode the interval invalue(e.g. 100 = "every 100 XP") but the bonus amount is only in the description string. There is no structured way to parse or compute these.What Needs to Change
BonusSpectype totypes/disciplines.tswith concrete fields:{ stat: string; amount: number }so perks carry structured bonus data instead of hiding it in description strings.computeDisciplineEffects()to:onceperks: addbonus.amounttobonuses[bonus.stat]when threshold is metinfiniteperks: calculate tier viacalculatePerkTier()and addtier * bonus.amounttobonuses[bonus.stat]cappedperks: calculate tier and add to a known multiplier key (not a namespaced orphan)specials.add(perk.id)for perks that now apply their bonuses throughbonuses/multipliersdirectly.Files Involved
src/lib/game/types/disciplines.ts— addBonusSpectypesrc/lib/game/effects/discipline-effects.ts— rewrite perk handlingsrc/lib/game/effects.ts— ensure merged stat keys consume the new bonus pathssrc/lib/game/data/disciplines/*.ts— populate structured bonus data on each perkTest References
src/lib/game/__tests__/discipline-math.test.ts—calculatePerkTierandgetUnlockedPerkstests exist but don't verify numerical applicationfix: Discipline perk numerical bonuses are dead code — once/infinite/capped perks don't applyto [priority: highest] fix: Discipline perk numerical bonuses are dead code — once/infinite/capped perks don't applyStarting work on making discipline perk numerical bonuses functional. Will: (1) add BonusSpec type, (2) update discipline data files, (3) rewrite computeDisciplineEffects() perk handling.
Fixed. All three critical bugs resolved:
Type system: Added
PerkBonusinterface and optionalbonusfield toDisciplinePerkintypes/disciplines.tsData files: Added structured bonus data to 39 perks across 5 discipline files:
base.ts: raw-mastery-1 (+50 maxManaBonus), raw-mastery-2 (infinite +25 maxManaBonus per 100 XP)elemental.ts: 7 elemental attunement perks (+10 elementCap per element)elemental-regen.ts: 16 regen perks (+regen per element, both once and infinite)elemental-regen-advanced.ts: 12 regen perks (composite + exotic elements)invoker.ts: spell-1 (+10 baseDamageBonus), spell-2 (infinite +5 baseDamageBonus per 300 XP)Effects computation: Rewrote
computeDisciplineEffects()indiscipline-effects.tsto:onceperks: addbonus.amounttobonuses[stat]infiniteperks: calculate tier viacalculatePerkTier(), addtier * bonus.amountcappedperks: calculate tier and add to bonus statunlocksEffectshandling (delegated to discipline-slice.ts)specials.add()for qualitative perksPer-element routing: Added
elementCap_*handling ineffects.tscomputeAllEffects()to merge intoperElementCapBonusmapAll 885 tests pass. Pre-commit checks pass. Committed as
da4f9ec.