feat: implement DoT/debuff runtime system (spec §6, AC-12, AC-13)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m18s

- Add ActiveEffect, EffectType types to game.ts; activeEffects + effectiveArmor on EnemyState
- Add SpellOnHitEffect + onHitEffect field to SpellDefinition
- Wire onHitEffect to fire (burn), death (curse), lightning (armor_corrode), frost (freeze), soul (bypassArmor burn)
- Add applyOnHitEffect() — applies on-hit effect on successful spell hit (spec §6.2)
- Add processDoTPhase() — ticks all active effects after weapon/golem attacks (spec §6.3)
- Add bypassArmor/bypassBarrier support in applyEnemyDefenses() (AC-13)
- Export standalone applyEnemyDefenses from combat-tick.ts for DoT pipeline
- Split DoT runtime into separate dot-runtime.ts (135 lines) to keep combat-actions.ts under 400 lines
- Update all enemy generation sites with activeEffects/effectiveArmor defaults
- Fix test helpers for new required fields

All 921 tests pass (45 test files)
This commit is contained in:
2026-06-03 18:38:01 +02:00
parent a2cdf6d21c
commit b506f0bcc3
30 changed files with 3272 additions and 71 deletions
@@ -0,0 +1,363 @@
# Enchanter Attunement — Design Spec
> Describes the Enchanter attunement: identity, unlock flow, mana behavior, full
> discipline list with stats/perks, systems unlocked, and attunement level interactions.
---
## 1. Objective
The Enchanter is the starting attunement and the gateway to the enchanting system.
It provides access to Transference-based disciplines that unlock enchantment
effects, boost enchantment power, and provide study/utility bonuses. The Enchanter
is always the first attunement a player uses, and it remains relevant throughout
all stages of the game through its 10 disciplines and the deep enchanting pipeline.
---
## 2. Identity
| Property | Value |
|---|---|
| **ID** | `enchanter` |
| **Slot** | `rightHand` |
| **Icon** | `✨` |
| **Color** | `#1ABC9C` (Teal) |
| **Primary Mana** | `transference` |
| **Raw Mana Regen** | +0.5/hour (base, scales with `1.5^(level-1)`) |
| **Conversion Rate** | 0.2 raw→transference/hour (base, scales with `1.5^(level-1)`) |
| **Unlock** | Starting attunement (unlocked by default) |
| **Capabilities** | `['enchanting']` |
| **Skill Categories** | `['enchant', 'effectResearch']` |
---
## 3. Unlock Condition and Flow
The Enchanter is **always unlocked** — it is present in the initial game state:
```typescript
attunements: {
enchanter: { id: 'enchanter', active: true, level: 1, experience: 0 }
}
```
No unlock flow is required. The player begins the game with Enchanter active.
---
## 4. Raw Mana Regen Contribution
Base regen: **+0.5/hour** (at level 1). Scales exponentially:
```
effectiveRegen = 0.5 × 1.5^(level - 1)
```
| Level | Raw Regen |
|---|---|
| 1 | 0.500/hr |
| 5 | 2.531/hr |
| 10 | 19.221/hr |
---
## 5. Mana Conversion Behavior
The Enchanter is the **only attunement that converts raw mana to Transference**:
```
effectiveConversionRate = 0.2 × 1.5^(level - 1)
```
This is an automatic per-hour conversion. Each tick:
- `0.2 × 1.5^(level-1) × HOURS_PER_TICK` raw mana is consumed
- The same amount is added to the Transference mana pool
At level 10, the Enchanter converts **7.69 raw→transference/hour**.
---
## 6. Disciplines
The Enchanter's discipline pool contains **10 disciplines** across 4 files.
### 6.1 Core Disciplines (`enchanter.ts`) — 4 disciplines
#### Enchantment Crafting (`enchant-crafting`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 8 |
| **Stat Bonus** | `enchantPower` +8 (base) |
| **Scaling Factor** | 60 |
| **Difficulty Factor** | 120 |
| **Drain Base** | 3 |
| Perk ID | Type | Threshold | Bonus |
|---|---|---|---|
| `enchant-1` | `infinite` | 150 | +5 enchantPower per tier (repeats every 150 XP) |
| `enchant-2` | `capped` | 300 | +10 enchantPower per tier, interval 200 XP, max 3 tiers |
#### Mana Channeling (`mana-channeling`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 12 |
| **Stat Bonus** | `clickManaMultiplier` +0.3 (base) |
| **Scaling Factor** | 90 |
| **Difficulty Factor** | 180 |
| **Drain Base** | 5 |
| Perk ID | Type | Threshold | Bonus |
|---|---|---|---|
| `channel-1` | `once` | 250 | `elementCap_lightning` +15 |
#### Study Basic Weapon Enchantments (`study-basic-weapon-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 10 |
| **Stat Bonus** | `enchantPower` +3 (base) |
| **Scaling Factor** | 80 |
| **Difficulty Factor** | 100 |
| **Drain Base** | 2 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `basic-weapon-fire` | `once` | 50 | `sword_fire` |
| `basic-weapon-frost` | `once` | 100 | `sword_frost` |
| `basic-weapon-lightning` | `once` | 150 | `sword_lightning` |
#### Study Advanced Weapon Enchantments (`study-advanced-weapon-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 20 |
| **Requires** | `study-basic-weapon-enchantments` |
| **Stat Bonus** | `enchantPower` +5 (base) |
| **Scaling Factor** | 120 |
| **Difficulty Factor** | 200 |
| **Drain Base** | 4 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `advanced-weapon-void` | `once` | 100 | `sword_void` |
| `advanced-weapon-damage-5` | `once` | 150 | `damage_5` |
| `advanced-weapon-crit` | `once` | 200 | `crit_5` |
| `advanced-weapon-attack-speed` | `once` | 250 | `attack_speed_10` |
### 6.2 Utility Disciplines (`enchanter-utility.ts`) — 2 disciplines
#### Study Utility Enchantments (`study-utility-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 8 |
| **Stat Bonus** | `studySpeed` +0.05 (base) |
| **Scaling Factor** | 60 |
| **Difficulty Factor** | 80 |
| **Drain Base** | 2 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `utility-meditate` | `once` | 50 | `meditate_10` |
| `utility-study` | `once` | 100 | `study_10` |
| `utility-insight` | `once` | 150 | `insight_5` |
#### Study Mana Enchantments (`study-mana-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 15 |
| **Stat Bonus** | `maxManaBonus` +10 (base) |
| **Scaling Factor** | 100 |
| **Difficulty Factor** | 150 |
| **Drain Base** | 3 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `mana-cap-50` | `once` | 75 | `mana_cap_50` |
| `mana-cap-100` | `once` | 150 | `mana_cap_100` |
| `mana-regen-1` | `once` | 100 | `mana_regen_1` |
| `mana-regen-2` | `once` | 200 | `mana_regen_2` |
| `click-mana-1` | `once` | 125 | `click_mana_1` |
| `click-mana-3` | `once` | 225 | `click_mana_3` |
### 6.3 Spell Disciplines (`enchanter-spells.ts`) — 3 disciplines
#### Study Basic Spell Enchantments (`study-basic-spell-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 18 |
| **Stat Bonus** | `enchantPower` +4 (base) |
| **Scaling Factor** | 100 |
| **Difficulty Factor** | 160 |
| **Drain Base** | 3 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `spell-mana-bolt` | `once` | 50 | `spell_manaBolt` |
| `spell-fireball` | `once` | 100 | `spell_fireball` |
| `spell-water-jet` | `once` | 100 | `spell_waterJet` |
| `spell-gust` | `once` | 100 | `spell_gust` |
| `spell-stone-bullet` | `once` | 100 | `spell_stoneBullet` |
| `spell-light-lance` | `once` | 150 | `spell_lightLance` |
| `spell-shadow-bolt` | `once` | 150 | `spell_shadowBolt` |
| `spell-drain` | `once` | 150 | `spell_drain` |
#### Study Intermediate Spell Enchantments (`study-intermediate-spell-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 25 |
| **Requires** | `study-basic-spell-enchantments` |
| **Stat Bonus** | `enchantPower` +6 (base) |
| **Scaling Factor** | 150 |
| **Difficulty Factor** | 250 |
| **Drain Base** | 5 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `spell-inferno` | `once` | 100 | `spell_inferno` |
| `spell-tidal-wave` | `once` | 100 | `spell_tidalWave` |
| `spell-earthquake` | `once` | 120 | `spell_earthquake` |
| `spell-chain-lightning` | `once` | 100 | `spell_chainLightning` |
| `spell-metal-shard` | `once` | 80 | `spell_metalShard` |
| `spell-sand-blast` | `once` | 80 | `spell_sandBlast` |
#### Study Advanced Spell Enchantments (`study-advanced-spell-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 35 |
| **Requires** | `study-intermediate-spell-enchantments` |
| **Stat Bonus** | `enchantPower` +10 (base) |
| **Scaling Factor** | 200 |
| **Difficulty Factor** | 350 |
| **Drain Base** | 7 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `spell-pyroclasm` | `once` | 100 | `spell_pyroclasm` |
| `spell-tsunami` | `once` | 100 | `spell_tsunami` |
| `spell-meteor-strike` | `once` | 120 | `spell_meteorStrike` |
| `spell-heaven-light` | `once` | 100 | `spell_heavenLight` |
| `spell-oblivion` | `once` | 100 | `spell_oblivion` |
| `spell-furnace-blast` | `once` | 100 | `spell_furnaceBlast` |
| `spell-dune-collapse` | `once` | 100 | `spell_duneCollapse` |
| `spell-stellar-nova` | `once` | 200 | `spell_stellarNova` |
| `spell-void-collapse` | `once` | 180 | `spell_voidCollapse` |
| `spell-crystal-shatter` | `once` | 160 | `spell_crystalShatter` |
### 6.4 Special Discipline (`enchanter-special.ts`) — 1 discipline
#### Study Special Enchantments (`study-special-enchantments`)
| Field | Value |
|---|---|
| **Mana Type** | `transference` |
| **Base Cost** | 22 |
| **Requires** | `study-advanced-weapon-enchantments` |
| **Stat Bonus** | `enchantPower` +5 (base) |
| **Scaling Factor** | 130 |
| **Difficulty Factor** | 220 |
| **Drain Base** | 4 |
| Perk ID | Type | Threshold | Unlocks |
|---|---|---|---|
| `special-spell-echo` | `once` | 100 | `spell_echo_10` |
| `special-guardian-dmg` | `once` | 80 | `guardian_dmg_10` |
| `special-overpower` | `once` | 150 | `overpower_80` |
| `special-first-strike` | `once` | 120 | `first_strike` |
| `special-combo-master` | `once` | 200 | `combo_master` |
| `special-adrenaline-rush` | `once` | 180 | `adrenaline_rush` |
---
## 7. Systems Unlocked
The Enchanter attunement gates the **Enchanting System** (see `enchanting-spec.md`):
- **Design** stage: Create named enchantment designs
- **Prepare** stage: Clear existing enchantments, ready equipment
- **Apply** stage: Apply saved designs to prepared equipment
---
## 8. Puzzle Room Behavior
In the spire, every 7th floor has a puzzle room. When the room type is
`enchanter_trial`, progress scales at 2.53% per tick per Enchanter level.
---
## 9. Attunement Level Interactions
Higher Enchanter level affects:
1. **Raw mana regen**: `0.5 × 1.5^(level-1)` per hour
2. **Transference conversion rate**: `0.2 × 1.5^(level-1)` per hour
3. **Enchanting XP → Attunement XP**: Enchanting awards Enchanter XP (1 per 10 capacity used), feeding back into leveling
Attunement level does **not** directly affect enchantment strength or discipline
power — those scale through discipline XP alone.
---
## 10. Discipline Dependency Chain
```
enchant-crafting (root)
mana-channeling (root)
study-basic-weapon-enchantments (root)
└── study-advanced-weapon-enchantments
└── study-special-enchantments
study-utility-enchantments (root)
study-mana-enchantments (root)
study-basic-spell-enchantments (root)
└── study-intermediate-spell-enchantments
└── study-advanced-spell-enchantments
```
6 root disciplines. Maximum dependency depth: 3.
---
## 11. Acceptance Criteria
| # | Criterion |
|---|---|
| AC-1 | Enchanter starts unlocked at level 1 with 0 XP. |
| AC-2 | All 10 Enchanter disciplines are available when Enchanter is active. |
| AC-3 | Discipline dependency chains are enforced — Advanced Weapon Enchantments requires Basic Weapon Enchantments. |
| AC-4 | All perk thresholds unlock the correct enchantment effects at the specified XP values. |
| AC-5 | Enchantment Power stat bonus from all active Enchanter disciplines stacks additively. |
| AC-6 | The `enchant-1` infinite perk grants +5 enchantPower every 150 XP beyond threshold. |
| AC-7 | The `enchant-2` capped perk grants +10 enchantPower per tier, max 3 tiers, interval 200 XP beyond threshold. |
| AC-8 | Enchanting system is accessible when Enchanter is active, locked when inactive. |
| AC-9 | Enchanter `enchanter_trial` puzzle rooms grant bonus progress per Enchanter level. |
| AC-10 | Enchanter level scales raw regen and conversion rate by `1.5^(level-1)`. |
---
## 12. Files Reference
| File | Role |
|---|---|
| `src/lib/game/data/attunements.ts` | Enchanter definition |
| `src/lib/game/data/disciplines/enchanter.ts` | Core Enchanter disciplines (4) |
| `src/lib/game/data/disciplines/enchanter-utility.ts` | Utility enchantment disciplines (2) |
| `src/lib/game/data/disciplines/enchanter-spells.ts` | Spell enchantment disciplines (3) |
| `src/lib/game/data/disciplines/enchanter-special.ts` | Special enchantment discipline (1) |
| `docs/specs/attunements/enchanter/systems/enchanting-spec.md` | Enchanting system spec |