Port the remaining battle items, the stats screen and hBattleTurn at the menu

- Run every non-ball item effect usable in battle from the ROM's
  ItemEffects: Full Restore, revives, bitter medicine, Bitter Berry, Ethers
  and Elixers, X items, X Accuracy, Guard Spec, Dire Hit and Poké Doll.
- Read happiness changes from HappinessChanges, including the larger
  level-up gain where a Pokémon was caught.
- Model hBattleTurn at the battle menu, including the trainer AI's writes,
  and drop the status-heal refusal.
- Port the stats screen for battles and Bill's PC.
- Compare the send-out and withdraw texts, RestoreHealth, RestorePP,
  ChangeHappiness and CalcPlayerStats with the original routines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-09-30 11:24:55 +02:00
1 parent cfd083c16d
commit b13e09ec20
22 files changed
+1547 -171

No files matched your search

+42 -2
View File
@@ -1,7 +1,7 @@
# Recovered Claude session
Latest continuation: see **Remaining opening-milestone items: 2026-09-30** at the end of
this file. Earlier sections are historical snapshots.
Latest continuation: see **Battle items, hBattleTurn and the stats screen: 2026-09-30**
at the end of this file. Earlier sections are historical snapshots.
Recovered on 2026-09-23 from the local Claude Code transcript
`~/.claude/projects/-Users-kawa-Crystal/4ac88f30-29e6-4fd5-a4b2-b6a318dd83b3.jsonl`.
@@ -566,3 +566,43 @@ Next (PLAN section 2): controlled-seed comparisons of random-driven
battle routines. Then PLAN section 3/4 items: the party and bag menus
outside battle (with the stats screen and MOVE PKMN W/O MAIL), evolution
itself, and the remaining battle items.
## Battle items, hBattleTurn and the stats screen: 2026-09-30
After `f8e0f9c`/`cfd083c`, the user asked for the items the previous
summary listed as refused or not ported:
- Every non-ball item effect usable in battle, found by reading each
item's battle context and `ItemEffects` entry from the ROM: Full
Restore, Revive/Max Revive, Energypowder, Energy Root, Heal Powder,
Revival Herb, Bitter Berry, Ether/Max Ether/Elixer/Max Elixer/
MysteryBerry (new `move` prompt), X items, X Accuracy, Guard Spec, Dire
Hit and Poké Doll. `ChangeHappiness` now reads `HappinessChanges`
(including the `wPartyMenuCursor` quirk), which also fixed level-ups:
`LevelUpHappinessMod`'s larger gain where the Pokémon was caught was
missing (new `landmark` battle option). A second participant set
(`wBattleParticipantsIncludingFainted`) serves revives.
- `hBattleTurn` at the battle menu: `DoBattle` ends on the player's turn,
full turns end on the enemy's, and `chooseTrainerMove` now returns
`enemyTurn` when `AI_Types`, `AI_Status` or `AIDamageCalc` ran. The
status-heal refusal is gone; the enemy's penalty is reapplied as in the
original.
- Stats screen: three pages from ROM strings (`STATS` profile table,
verified by `check:reference`), `TypeNames` and `GetGender`. It opens from
BattleMonMenu and from Bill's PC (a `stats` script effect;
`world.statsScreen`).
- Emulator comparisons: a new reference test runs `SendOutMonText` (with
its final `jp BattleTextbox` patched to `ret` in the in-page ROM copy),
`WithdrawMonText`'s text routine, `RestoreHealth` (with `wHPBuffer1` set
as `ItemRestoreHP` leaves it), `RestorePP`, `ChangeHappiness` and
`CalcPlayerStats` with both turns. A mutation of `calcPlayerStats` was
confirmed to fail. The pure helpers are exported from `battle.ts`.
Remaining: Kurt's and the Park Ball; the leftover multiplicand byte in
`WithdrawMonText` is assumed zero; no whole battle has been compared with
the original.
Checks: 337 unit tests with the local ROM (131 passed, 206 skipped
without it); 97 Chromium/WebKit browser tests passed, 19 skipped
intentionally; native and reference builds; reference, release and
vendor checks; `git diff --check`. Not committed.