[priority: medium-high] refactor: Replace natural-regen disciplines with mana conversion speed disciplines #139

Closed
opened 2026-05-26 15:26:05 +02:00 by Anexim · 2 comments
Owner

Problem

There are currently 14 elemental regen disciplines (8 in elemental-regen.ts, 6 in elemental-regen-advanced.ts) that passively generate element mana from nothing using regen_{element} stat bonuses. The design intent has changed: these should instead speed up mana conversion from raw mana (and/or constituent mana types) to the target mana type, following the same zero-sum transfer pattern used by attunement conversions.

Current System (to be removed)

Each discipline adds regen_{element} to disciplineEffects.bonuses, and the tick in gameStore.ts applies value * HOURS_PER_TICK directly to elements[element].current — creating mana from nothing.

New System (to be implemented)

Each element discipline should define a conversion rate (similar to attunement conversionRate). The tick should:

  1. Drain raw mana (or constituent elements for composites/exotics) proportional to the conversion rate
  2. Add the converted amount to the target element's pool
  3. Be gated — the discipline can only run if the player has access to all required source mana types

Conversion Recipes (from elements.ts)

Target Source Mana Types
fire raw → fire
water raw → water
air raw → air
earth raw → earth
light raw → light
dark raw → dark
death raw → death
transference raw → transference
metal raw + fire + earth → metal
sand raw + earth + water → sand
lightning raw + fire + air → lightning
crystal raw + sand + sand + light → crystal
stellar raw + fire + fire + light → stellar
void raw + dark + dark + death → void

(Base elements: raw mana only. Composites: raw + constituent base elements. Exotics: raw + constituent composite/base elements.)

Locking Requirements

  • Each discipline must be locked until the player has access to all source mana types (e.g. Metal Mana Flow requires fire mana AND earth mana — the player must have signed the fire guardian AND the earth guardian pact).
  • The requires field on these disciplines should reference guardian floor numbers or mana type access checks, NOT prerequisite discipline IDs.
  • The UI should display Requires: fire mana, earth mana (element names), not Requires: fire (raw IDs).

What Needs to Change

Data Layer

  1. src/lib/game/data/disciplines/elemental-regen.ts — rewrite all 8 base disciplines with conversionRate instead of regen_* statBonus
  2. src/lib/game/data/disciplines/elemental-regen-advanced.ts — rewrite all 6 composite/exotic disciplines similarly
  3. Remove regen_{element} stat keys, replace with conversionRate + sourceManaTypes[] fields on the discipline definition

Type Layer

  1. src/lib/game/types/disciplines.ts — add conversionRate and sourceManaTypes fields to DisciplineDefinition

Effect Layer

  1. src/lib/game/effects/discipline-effects.ts — instead of adding to bonuses['regen_*'], disciplines with conversionRate should produce a conversion entry
  2. Create a new conversionSpeed map in the effect system (similar to perElementRegenBonus)

Tick Pipeline

  1. src/lib/game/stores/gameStore.ts — replace the regen_* bonus application (lines ~277-289) with a conversion step:
    • For each active discipline with conversionRate: drain source mana types, add to target element
    • Respect element max capacity
    • Gate on having all source mana types unlocked

Prerequisite Display

  1. src/lib/game/utils/discipline-math.tscheckDisciplinePrerequisites() should resolve mana type IDs to names like "fire mana" instead of "fire"
  2. src/lib/game/stores/discipline-slice.tsactivate() should gate on having source mana types unlocked

Files

  • src/lib/game/types/disciplines.ts
  • src/lib/game/data/disciplines/elemental-regen.ts (full rewrite)
  • src/lib/game/data/disciplines/elemental-regen-advanced.ts (full rewrite)
  • src/lib/game/effects/discipline-effects.ts
  • src/lib/game/effects.ts
  • src/lib/game/stores/gameStore.ts
  • src/lib/game/stores/discipline-slice.ts
  • src/lib/game/utils/discipline-math.ts
  • src/lib/game/components/game/tabs/DisciplinesTab.tsx (prereq display)
## Problem There are currently 14 elemental regen disciplines (8 in `elemental-regen.ts`, 6 in `elemental-regen-advanced.ts`) that passively generate element mana from nothing using `regen_{element}` stat bonuses. The design intent has changed: these should instead **speed up mana conversion** from raw mana (and/or constituent mana types) to the target mana type, following the same zero-sum transfer pattern used by attunement conversions. ## Current System (to be removed) Each discipline adds `regen_{element}` to `disciplineEffects.bonuses`, and the tick in `gameStore.ts` applies `value * HOURS_PER_TICK` directly to `elements[element].current` — creating mana from nothing. ## New System (to be implemented) Each element discipline should define a **conversion rate** (similar to attunement `conversionRate`). The tick should: 1. **Drain raw mana** (or constituent elements for composites/exotics) proportional to the conversion rate 2. **Add the converted amount** to the target element's pool 3. **Be gated** — the discipline can only run if the player has access to all required source mana types ## Conversion Recipes (from `elements.ts`) | Target | Source Mana Types | |--------|------------------| | fire | raw → fire | | water | raw → water | | air | raw → air | | earth | raw → earth | | light | raw → light | | dark | raw → dark | | death | raw → death | | transference | raw → transference | | metal | raw + fire + earth → metal | | sand | raw + earth + water → sand | | lightning | raw + fire + air → lightning | | crystal | raw + sand + sand + light → crystal | | stellar | raw + fire + fire + light → stellar | | void | raw + dark + dark + death → void | *(Base elements: raw mana only. Composites: raw + constituent base elements. Exotics: raw + constituent composite/base elements.)* ## Locking Requirements - Each discipline must be **locked until the player has access to all source mana types** (e.g. Metal Mana Flow requires fire mana AND earth mana — the player must have signed the fire guardian AND the earth guardian pact). - The `requires` field on these disciplines should reference **guardian floor numbers** or mana type access checks, NOT prerequisite discipline IDs. - The UI should display `Requires: fire mana, earth mana` (element names), not `Requires: fire` (raw IDs). ## What Needs to Change ### Data Layer 1. `src/lib/game/data/disciplines/elemental-regen.ts` — rewrite all 8 base disciplines with `conversionRate` instead of `regen_*` statBonus 2. `src/lib/game/data/disciplines/elemental-regen-advanced.ts` — rewrite all 6 composite/exotic disciplines similarly 3. Remove `regen_{element}` stat keys, replace with `conversionRate` + `sourceManaTypes[]` fields on the discipline definition ### Type Layer 4. `src/lib/game/types/disciplines.ts` — add `conversionRate` and `sourceManaTypes` fields to `DisciplineDefinition` ### Effect Layer 5. `src/lib/game/effects/discipline-effects.ts` — instead of adding to `bonuses['regen_*']`, disciplines with `conversionRate` should produce a conversion entry 6. Create a new `conversionSpeed` map in the effect system (similar to `perElementRegenBonus`) ### Tick Pipeline 7. `src/lib/game/stores/gameStore.ts` — replace the `regen_*` bonus application (lines ~277-289) with a conversion step: - For each active discipline with `conversionRate`: drain source mana types, add to target element - Respect element max capacity - Gate on having all source mana types unlocked ### Prerequisite Display 8. `src/lib/game/utils/discipline-math.ts` — `checkDisciplinePrerequisites()` should resolve mana type IDs to names like `"fire mana"` instead of `"fire"` 9. `src/lib/game/stores/discipline-slice.ts` — `activate()` should gate on having source mana types unlocked ## Files - `src/lib/game/types/disciplines.ts` - `src/lib/game/data/disciplines/elemental-regen.ts` (full rewrite) - `src/lib/game/data/disciplines/elemental-regen-advanced.ts` (full rewrite) - `src/lib/game/effects/discipline-effects.ts` - `src/lib/game/effects.ts` - `src/lib/game/stores/gameStore.ts` - `src/lib/game/stores/discipline-slice.ts` - `src/lib/game/utils/discipline-math.ts` - `src/lib/game/components/game/tabs/DisciplinesTab.tsx` (prereq display)
Anexim added the ai:todo label 2026-05-26 15:26:05 +02:00
n8n-gitea was assigned by Anexim 2026-05-26 15:26:05 +02:00
Anexim changed title from refactor: Replace natural-regen disciplines with mana conversion speed disciplines to [priority: high] refactor: Replace natural-regen disciplines with mana conversion speed disciplines 2026-05-26 15:29:28 +02:00
Anexim changed title from [priority: high] refactor: Replace natural-regen disciplines with mana conversion speed disciplines to [priority: medium-high] refactor: Replace natural-regen disciplines with mana conversion speed disciplines 2026-05-26 15:30:09 +02:00
Author
Owner

Starting work on replacing natural-regen disciplines with mana conversion speed disciplines. Plan:

  1. Update DisciplineDefinition type to support conversionRate + sourceManaTypes
  2. Rewrite elemental-regen.ts (8 base disciplines)
  3. Rewrite elemental-regen-advanced.ts (6 composite/exotic disciplines)
  4. Update discipline-effects.ts to produce conversion entries instead of regen bonuses
  5. Update gameStore.ts tick pipeline to apply conversion instead of regen
  6. Update discipline-slice.ts to gate on source mana type access
  7. Update discipline-math.ts for prerequisite display
  8. Update DisciplinesTab.tsx for UI display
Starting work on replacing natural-regen disciplines with mana conversion speed disciplines. Plan: 1. Update DisciplineDefinition type to support conversionRate + sourceManaTypes 2. Rewrite elemental-regen.ts (8 base disciplines) 3. Rewrite elemental-regen-advanced.ts (6 composite/exotic disciplines) 4. Update discipline-effects.ts to produce conversion entries instead of regen bonuses 5. Update gameStore.ts tick pipeline to apply conversion instead of regen 6. Update discipline-slice.ts to gate on source mana type access 7. Update discipline-math.ts for prerequisite display 8. Update DisciplinesTab.tsx for UI display
Author
Owner

Complete. Replaced all 14 natural-regen disciplines with mana conversion speed disciplines.

Changes (12 files, 430 insertions, 263 deletions):

  • types/disciplines.ts — Added conversionRate and sourceManaTypes fields to DisciplineDefinition
  • data/disciplines/elemental-regen.ts — Rewrote all 8 base disciplines to convert raw→element instead of passive regen
  • data/disciplines/elemental-regen-advanced.ts — Rewrote all 6 composite/exotic disciplines with proper source recipes (e.g. metal: raw+fire+earth)
  • effects/discipline-effects.ts — Now produces conversions map instead of regen_{element} bonuses; conversion rate scales with XP via stat bonus
  • stores/gameStore.ts — Tick pipeline now drains all source mana types and adds to target element, gated on having sufficient source mana
  • stores/discipline-slice.tsactivate() now gates on all source mana types being unlocked (not just the target)
  • utils/discipline-math.tscheckDisciplinePrerequisites() resolves unknown IDs as mana type requirements, displaying as "X mana" (e.g. "fire mana, earth mana")
  • components/game/tabs/DisciplinesTab.tsx — Shows conversion recipes ("Converts: raw + fire + earth → Metal"), locks disciplines missing source mana, passes elements to activate()
  • components/game/tabs/DebugTab/DisciplineDebugSection.tsx — Passes elements to activate()
  • effects.ts — Removed regen_{element} merge loop (no longer produced)

All 885 tests pass. Files within 400-line limit.

✅ Complete. Replaced all 14 natural-regen disciplines with mana conversion speed disciplines. Changes (12 files, 430 insertions, 263 deletions): - **types/disciplines.ts** — Added `conversionRate` and `sourceManaTypes` fields to `DisciplineDefinition` - **data/disciplines/elemental-regen.ts** — Rewrote all 8 base disciplines to convert raw→element instead of passive regen - **data/disciplines/elemental-regen-advanced.ts** — Rewrote all 6 composite/exotic disciplines with proper source recipes (e.g. metal: raw+fire+earth) - **effects/discipline-effects.ts** — Now produces `conversions` map instead of `regen_{element}` bonuses; conversion rate scales with XP via stat bonus - **stores/gameStore.ts** — Tick pipeline now drains all source mana types and adds to target element, gated on having sufficient source mana - **stores/discipline-slice.ts** — `activate()` now gates on all source mana types being unlocked (not just the target) - **utils/discipline-math.ts** — `checkDisciplinePrerequisites()` resolves unknown IDs as mana type requirements, displaying as "X mana" (e.g. "fire mana, earth mana") - **components/game/tabs/DisciplinesTab.tsx** — Shows conversion recipes ("Converts: raw + fire + earth → Metal"), locks disciplines missing source mana, passes elements to activate() - **components/game/tabs/DebugTab/DisciplineDebugSection.tsx** — Passes elements to activate() - **effects.ts** — Removed `regen_{element}` merge loop (no longer produced) All 885 tests pass. Files within 400-line limit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#139