Port the trainer card and the play time

The player's name in the start menu opens TrainerCard: page 1 with the
name, ID, money, Pokédex count and play time, page 2 with the Johto
leaders and the badges owned, turned and closed with the original
buttons. The card picture, leader faces and animated badges come from the
ROM with _CGB_TrainerCard's palettes. GameTimer now counts the play time
from the end of the introduction, capped at 999:59:59, and saves keep it.

Closes #23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-10-01 13:32:14 +02:00
1 parent 38b9562bd3
commit 47698565ab
24 files changed
+954 -30

No files matched your search

+43
View File
@@ -886,3 +886,46 @@ run. Not committed.
Next: the trainer card and options; later the Fly map and Teleport/Dig
warps.
## Trainer card and play time: 2026-10-01
Resumed with "continue the plan" after `38b9562` (clean tree), taking the
recorded next item (the trainer card, board card #23). The Pokégear and
Mom's bank above were committed as `209778c`.
- `src/game/scripts/trainer-card.ts` (`TrainerCard`): the player's name in
the start menu runs the card and returns to the start menu. Each page is
a `trainercard` effect answered with a button (a `buttonChoice` like the
Pokégear): page 1 A/right → page 2; page 2 A leaves, left → page 1; B
leaves from both. The Kanto page (unreferenced code) is not shown. Labels
from `.Name_Money`, `.Dex_PlayTime` and `.Badges`; the Pokédex line only
with `ENGINE_POKEDEX`; badges from the Johto badge engine flags.
- `src/game/world/game-time.ts`: `wGameTime` and `GameTimer` (60 frames a
second, capped at 999:59:59.00). `GameWorld.gameTime` advances two
frames per tick unless the introduction is pending; `beginIntro` resets
it. `save()` during a scene returns the committed state with the current
play time. Saves gained `gameTime`, migrated by absence to zero.
- The world refreshes the card's time, blinking colon (every 32 frames on
page 1) and badge step (every 8 frames on page 2, only with badges) each
tick, counting from the page load.
- `src/game/rendering/trainer-card.ts`: the Chris/Kris card picture
(tile $1c left blank, as the corner covers it) and page 2's leader faces
with the owned badges' sprites, coloured by `_CGB_TrainerCard`'s
attribute map. UI: `#trainer-card` panel, frame colour from the other
gender's palette; checked visually at desktop and 390px widths.
- New `TRAINER_CARD` profile table, OW constants (`ENGINE_MINERALBADGE`,
`NUM_JOHTO_BADGES`, `PREDEFPAL_CGB_BADGE`, the leaders' trainer classes).
`check:reference` now understands the `trainerclass` macro.
- Tests that compare a save before and after a refused or rolled-back
action now ignore the play time (`withoutPlayTime` in
`tests/world-driver.ts`), which keeps counting.
Checks: 407 unit tests with the local ROM (134 passed, 273 skipped without
it; new `tests/trainer-card.test.ts`); 117 Chromium/WebKit browser tests
passed, 19 skipped intentionally (a new trainer card flow in both
browsers); native and reference builds; reference, vendor and release
checks; `git diff --check`. No emulator comparison of the card; no CI or
physical-device run.
Next: the options screen (board #24), then the Fly map and Teleport/Dig
warps.