C5: Add magic spellcasting #28

Merged
goose merged 2 commits from slice/c5-magic-spells into main 2026-10-03 15:07:31 +00:00
Showing only changes of commit d1eec579f8 - Show all commits
-43
View File
@@ -1,43 +0,0 @@
# Task C5 — Magic, Focus, and Spell Targeting
## Scope completed
C5 makes the existing `cast` command playable while retaining the established action, journal, combat-feedback, and targeting conventions.
- Added `SpellState` for learned spells and their per-spell cooldowns, plus `MagicEngine` for deterministic, data-backed spell validation and resolution.
- Spell casts use the ASCII content catalog. The initial run knows `spell_epines_empoisonnees`; its imported focus cost, damage, poison effect, range, and cooldown are applied.
- Added actor focus and status-effect state needed by C5. Invalid casts (unknown spell, cooldown, insufficient focus, invalid/dead/self target, range, or line-of-sight failure) do not spend focus or start a cooldown.
- Integrated `X` / `cast` with a spell-specific targeting overlay. Page Up/Page Down choose a learned spell, arrows choose a target, Enter casts, and Escape cancels.
- Valid casts journal structured spell events, resolve domain damage/death before asynchronous presentation, produce the established impact/death feedback, and permit the normal enemy response when the target survives.
- Added HUD focus display and spell-targeting scene. Expanded the stats panel to contain the added focus/spell lines and preserve the HUD layout contract.
- Added deterministic unit coverage for data-backed spell effects, cooldown rejection/decrement, and range/line-of-sight/focus rejection; E2E coverage exercises actual spell targeting, immediate resolution, presentation queuing, and blocked-target rejection.
## Verification
Executed from the C5 worktree with Godot 4.5:
```bash
GODOT_BIN=/snap/bin/godot4 ./scripts/verify.sh
```
Results:
| Suite | Tests | Assertions | Result |
| --- | ---: | ---: | --- |
| Unit | 111 | 884 | Passed |
| Integration | 7 | 9,255 | Passed |
| E2E | 27 | 271 | Passed |
| **Total** | **145** | **10,410** | **Passed** |
The full verifier ran both visual captures and passed their measurements:
| Capture | Size | Dungeon pixels | Visible | Explored | Unknown fog |
| --- | --- | ---: | ---: | ---: | ---: |
| `artifacts/visual-check.png` | 1280×720 | 489,308 | 17,524 | 10,438 | 366,411 |
| `artifacts/visual-check-exit.png` | 1280×720 | 489,252 | 17,404 | 17,146 | 440,583 |
The run emitted only the pre-existing GUT invalid-UID/resource-exit warnings plus the existing float/int-comparison test warning; it emitted no parse or script errors. Capture files and `artifacts/visual-check.log` are ignored build artifacts.
## Delivery boundary
Changes are confined to C5 spell/focus domain state and resolution, cast targeting and presentation, HUD support, C5 tests, and this root task report. No push or pull request was created.