import { CrystalAssets } from "../src/game/rom/assets"; import { generatePartyMon } from "../src/game/party/pokemon"; import { martFixtureWorld } from "./mart-fixture"; // Test-only script on an already accessible clerk. The actual trainer party, // class attributes, moves and battle text are read from the local ROM. export function trainerFixtureWorld(assets: CrystalAssets, tail = [0x60, 0x33, 0x00, 0x01, 0x91], lose = false, winText = false) { const clerk = assets.map("26:4").objects[0]; // Place the synthetic script in Joey's bank to test winlosstext's near pointer. if (winText) clerk.script = 0x68 * 0x4000 + 0x3f00; assets.reader.bytes.set([ 0x64, ...(winText ? [0xa2, 0x58] : [0, 0]), 0, 0, // Joey beaten text or default 0x5e, 22, 1, // loadtrainer YOUNGSTER, JOEY1 ...(lose ? [0x1e, 3, 1] : []), // loadvar VAR_BATTLETYPE, BATTLETYPE_CANLOSE 0x5f, ...tail, ], clerk.script); const world = martFixtureWorld(assets); const mon = generatePartyMon(assets.pokemon, { species: 155, level: lose ? 2 : 50, item: 0, otId: world.playerId, ot: "CHRIS", dvs: 0x823b, caughtData: 0, }); mon.moves = [33, 0, 0, 0]; mon.pp = [35, 0, 0, 0]; if (lose) mon.hp = 1; world.state.party = [mon]; world.state.pokedex.seen.add(155); world.state.pokedex.caught.add(155); return world; }