Add the TM/HM pocket, Egg screens and Violet's remaining scripts
Checks / web (push) Canceled after 0s

The pack's TM/HM pocket lists TMs and HMs with their moves, gives TMs and teaches either through the ABLE/NOT ABLE party menu, the compatibility and "already knows" checks and LearnMove; a TM is used up and makes the Pokémon happier. Eggs show no level or HP in the party menus, get the Egg stats page with its hatching hint, and are skipped by HealParty. Bug Catcher Wade's number registers (VAR_CALLERID and RandomPhoneMon).

The playthrough now runs through Falkner's ZEPHYRBADGE, the Togepi Egg, Kyle's Onix, Flash in Dark Cave, Wade's number and Earl's blackboard. With MAKE_TEST_SAVES it writes a Violet City backup for the manual checks.

Validated with 610 unit tests, 157 browser tests (including all 256 badge bytes against the original BadgeStatBoosts), native/reference builds and reference/vendor/release checks. Egg hatching (#29) and trainer calls (#30) remain on their cards.

Closes #31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-10-03 16:49:02 +02:00
1 parent 7909302db1
commit 73022b1505
13 files changed
+803 -31

No files matched your search

+89 -4
View File
@@ -7,7 +7,8 @@ import {
restoreHealth,
restoredPP,
} from "../battle/battle";
import { receiveItem, removeFromSlot, type ItemSlot } from "../party/bag";
import { receiveItem, removeFromSlot, tossItem, type ItemSlot } from "../party/bag";
import { HM01, NUM_TMS, tmhmItem, tmhmNumber } from "../rom/pokemon";
import { calcStats, maxPP, partyMonDetails, type PartyMon } from "../party/pokemon";
import type { GameTime } from "../world/game-time";
import { PartyEvolution, evoStoneCompatible } from "./evolution";
@@ -75,6 +76,7 @@ const {
PARTYMENUACTION_HEALING_ITEM,
PARTYMENUACTION_MOVE,
PARTYMENUACTION_GIVE_ITEM,
PARTYMENUACTION_TEACH_TMHM,
KEY_ITEM_POCKET,
TM_HM_POCKET,
PP_UP,
@@ -729,6 +731,10 @@ export class StartMenuRun {
yield { kind: "mail", mail: { ...mail } };
}
private giveItemToPokemon(pocket: PocketIndex, index: number, item: number) {
if (pocket === TM_HM_POCKET) {
if (!tossItem(this.state.bag, item, 1)) throw new Error("The item is not in the pack.");
return;
}
const list = this.pocketSlots(pocket);
if (!list || !removeFromSlot(list, index, item, 1))
throw new Error("The item is not in the pack.");
@@ -830,10 +836,25 @@ export class StartMenuRun {
const bag = this.state.bag;
return pocket === 0 ? bag.items : pocket === 1 ? bag.balls : undefined;
}
/** A pocket's list: quantities for items and balls, none for key items,
* and no TMs or HMs yet. */
/** A pocket's list: quantities for items and balls, none for key items;
* TMs (with a count) and HMs by number, with the move they teach
* (TMHM_DisplayPocketItems). */
private pocketEntries(pocket: PocketIndex): MartEntry[] {
const bag = this.state.bag;
if (pocket === TM_HM_POCKET)
return bag.tmsHms.flatMap((count, index) => {
if (!count) return [];
const number = index + 1,
item = tmhmItem(number);
return [
{
item,
name: `${this.data.itemName(item)} ${this.data.moveName(this.data.tmhmMove(number))}`,
price: 0,
...(number <= NUM_TMS && { owned: count }),
},
];
});
const slots: ItemSlot[] =
pocket === KEY_ITEM_POCKET
? bag.keyItems.map((item) => ({ item, quantity: 1 }))
@@ -934,11 +955,75 @@ export class StartMenuRun {
for (;;) {
const chosen = yield* this.choosePackItem(true);
if (!chosen) return false;
if (yield* this.itemSubmenu(chosen.pocket, chosen.index, chosen.item))
if (chosen.pocket === TM_HM_POCKET) yield* this.tmhmSubmenu(chosen.item);
else if (yield* this.itemSubmenu(chosen.pocket, chosen.index, chosen.item))
return true;
}
}
/** Pack's .TMHMPocketMenu: USE, GIVE and QUIT for a TM that can be
* tossed; USE and QUIT for an HM. */
private *tmhmSubmenu(item: number): Gen {
const tossable = !this.data.itemUnsellable(item);
const actions = tossable ? ["use", "give", "quit"] : ["use", "quit"];
const choice = yield* this.menu(
[this.data.itemName(item)],
this.stringList(tossable ? MENU["Pack.MenuData_2"] + 2 : MENU["Pack.MenuData_1"] + 2, actions.length),
);
const action = choice < 0 ? "quit" : actions[choice];
if (action === "give") return yield* this.giveItem(TM_HM_POCKET, 0, item);
if (action === "use") yield* this.teachTMHM(item);
}
/** AskTeachTMHM, ChooseMonToLearnTMHM and TeachTMHM: the move goes to a
* compatible Pokémon that does not know it, through LearnMove. A TM is
* used up and makes the Pokémon happier; an HM stays. */
private *teachTMHM(item: number): Gen {
const data = this.data,
number = tmhmNumber(item),
move = data.tmhmMove(number),
name = data.moveName(move);
// GetMoveName and CopyName1.
this.strings[RAM.stringBuffer1] = this.strings[RAM.stringBuffer2] = name;
yield* this.print(item >= HM01 ? MENU.BootedHMText : MENU.BootedTMText);
if (!(yield* this.yesNo(MENU.ContainedMoveText))) return;
const party = this.state.party;
let slot: number;
for (;;) {
// PlacePartyMonTMHMCompatibility: ABLE or NOT ABLE; nothing for Eggs.
const strings = MENU.PartyMenuStrings + PARTYMENUACTION_TEACH_TMHM * 2;
const prompt = this.string(this.reader.near(strings, this.reader.bank(strings)));
slot = yield* this.menu(
[prompt],
party.map((mon) => mon.nickname),
party.map((mon) =>
mon.egg
? ""
: this.string(
data.canLearnTMHM(mon.species, move)
? MENU["PlacePartyMonTMHMCompatibility.string_able"]
: MENU["PlacePartyMonTMHMCompatibility.string_not_able"],
),
),
);
if (slot < 0) return;
// An Egg plays SFX_WRONG and the menu stays.
if (!party[slot].egg) break;
}
const mon = party[slot];
this.strings[RAM.stringBuffer1] = mon.nickname;
this.strings[RAM.stringBuffer2] = name;
if (!data.canLearnTMHM(mon.species, move))
return yield* this.print(MENU.TMHMNotCompatibleText);
if (mon.moves.includes(move)) return yield* this.print(MENU["KnowsMove.KnowsMoveText"]);
const evolution = this.evolution();
evolution.strings[RAM.stringBuffer1] = evolution.strings[RAM.stringBuffer2] = name;
if (!(yield* evolution.learnMove(slot, move))) return;
if (item >= HM01) return;
this.changeHappiness(slot, C.HAPPINESS_LEARNMOVE);
// ConsumeTM
tossItem(this.state.bag, item, 1);
}
/** Pack.ItemBallsKey_LoadSubmenu: the submenu the item's permissions and
* field menu select. */
private *itemSubmenu(