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

+4 -4
View File
@@ -3,7 +3,7 @@ import { existsSync, readFileSync } from "node:fs";
import { CrystalAssets } from "../src/game/rom/assets";
import { C } from "../src/game/battle/constants";
import { martFixtureWorld, talkToClerk } from "./mart-fixture";
import { settle } from "./world-driver";
import { settle, withoutPlayTime } from "./world-driver";
const romPath = process.env.CRYSTAL_ROM_PATH ?? "Pokemon - Crystal Version (UE) (V1.1) [C][!].gbc";
const fixture = () => martFixtureWorld(new CrystalAssets(new Uint8Array(readFileSync(romPath))));
@@ -34,7 +34,7 @@ describe.skipIf(!existsSync(romPath))("Cherrygrove Mart with the local ROM", ()
const shown = settle(world, [0, 0, 1, 1, -1, 2]);
expect(world.notice, world.diagnostic).toBe("");
expect(shown.join("\n")).toMatch(/enough money/i);
expect(world.save()).toEqual(committed);
expect(withoutPlayTime(world.save())).toEqual(withoutPlayTime(committed));
});
it("refuses to buy into a full pocket, changing nothing", () => {
@@ -55,7 +55,7 @@ describe.skipIf(!existsSync(romPath))("Cherrygrove Mart with the local ROM", ()
const shown = settle(world, [0, 0, 1, 1, -1, 2]);
expect(world.notice, world.diagnostic).toBe("");
expect(shown.join("\n")).toMatch(/can't carry/i);
expect(world.save()).toEqual(committed);
expect(withoutPlayTime(world.save())).toEqual(withoutPlayTime(committed));
});
it("sells items at half the ROM price", () => {
@@ -116,7 +116,7 @@ describe.skipIf(!existsSync(romPath))("Cherrygrove Mart with the local ROM", ()
talkToClerk(world);
settle(world, [2]);
expect(world.notice, world.diagnostic).toBe("");
expect(world.save()).toEqual(before);
expect(withoutPlayTime(world.save())).toEqual(withoutPlayTime(before));
});
it("a mid-interaction save restores the committed state and replays it", () => {