mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
142 lines
5.3 KiB
Lua
142 lines
5.3 KiB
Lua
-- Assertion driver: the Pokegear radio's song outlives the gear, and the
|
|
-- Vermilion Snorlax hears it.
|
|
--
|
|
-- POKEPORT_GAME=gold POKEPORT_IDENTITY=gold-dev \
|
|
-- POKEPORT_DRIVER=tests/drivers/gold_radio_persist.lua love .
|
|
--
|
|
-- The chain under test, all through the real screens: engine flags written by
|
|
-- World:setEngineFlag (the store every granting script's `setflag` lands in)
|
|
-- unlock the START menu's POKeGEAR row and the gear's cards; the radio card
|
|
-- tunes 20.0 to the POKe FLUTE channel (Kanto + ENGINE_EXPN_CARD); closing
|
|
-- the gear leaves the song playing as the map music
|
|
-- (ExitPokegearRadio_HandleMusic / RadioMusicRestartDE); and `special
|
|
-- SnorlaxAwake` then reads that very song and starts the BATTLETYPE_FORCEITEM
|
|
-- Snorlax fight.
|
|
local U = require("tests.drivers.util")
|
|
|
|
return function(game)
|
|
U.wait(45)
|
|
local world = game.world
|
|
assert(world and world.map, "gold world did not boot")
|
|
local Music = require("src.core.Music")
|
|
|
|
-- A party to fight with; the unlock flags go through the same store every
|
|
-- granting script's `setflag` writes.
|
|
local save = game.save
|
|
save.party = { {
|
|
species = "TYPHLOSION", name = "TYPHLOSION", nickname = "TYPHLOSION",
|
|
level = 60, hp = 180, maxHp = 180,
|
|
moves = { { id = "FLAMETHROWER", pp = 15, maxPp = 15 } },
|
|
} }
|
|
for _, flag in ipairs({ 0, 1, 2, 3, 4, 11 }) do
|
|
world:setEngineFlag(flag, true)
|
|
end
|
|
|
|
-- Beside the sleeping Snorlax: (33,8) is one of SnorlaxAwake's own
|
|
-- .ProximityCoords, and facing right reaches the doll's object cell (34,8).
|
|
assert(world:setMap("VERMILION_CITY", 33, 8, "right"),
|
|
"setMap failed for VERMILION_CITY")
|
|
U.wait(10)
|
|
|
|
local function top() return game.stack:top() end
|
|
local function topIs(id)
|
|
local t = top()
|
|
return t and t.screenId == id and t or nil
|
|
end
|
|
|
|
-- START -> the menu, with the POKeGEAR row unlocked by the flags alone.
|
|
U.tap(game, "start")
|
|
local menu
|
|
for _ = 1, 60 do
|
|
menu = topIs("Gen2StartMenu")
|
|
if menu then break end
|
|
U.wait(1)
|
|
end
|
|
assert(menu, "START did not open the start menu")
|
|
local ids = {}
|
|
for _, item in ipairs(menu.items) do ids[item.value] = true end
|
|
assert(ids.pokegear, "the POKeGEAR row is missing from the START menu")
|
|
assert(ids.pokedex, "the POKeDEX row is missing from the START menu")
|
|
U.log("START menu shows POKeDEX and POKeGEAR from the engine flags")
|
|
|
|
-- Down to the POKeGEAR row (POKeDEX, POKeMON, PACK, POKeGEAR) and in.
|
|
for _ = 1, 3 do U.tap(game, "down") U.wait(2) end
|
|
U.tap(game, "a")
|
|
local gear
|
|
for _ = 1, 60 do
|
|
gear = topIs("Gen2Pokegear")
|
|
if gear then break end
|
|
U.wait(1)
|
|
end
|
|
assert(gear, "the POKeGEAR row did not open the gear")
|
|
assert(#gear.cards == 4, "expected all four cards, got " .. #gear.cards)
|
|
|
|
-- Strip: CLOCK, MAP, RADIO, PHONE. Two rights and A is the radio card.
|
|
U.tap(game, "right") U.wait(2)
|
|
U.tap(game, "right") U.wait(2)
|
|
U.tap(game, "a") U.wait(2)
|
|
assert(gear.mode == "card" and gear:card().id == "radio",
|
|
"did not land on the radio card")
|
|
|
|
-- Wind the knob to 20.0: RADIO_CHANNELS row 7, six UPs from row 1.
|
|
for _ = 1, 6 do U.tap(game, "up") U.wait(2) end
|
|
assert(gear.radioShow == "POKE_FLUTE_RADIO",
|
|
"20.0 did not resolve the POKe FLUTE channel (got "
|
|
.. tostring(gear.radioShow) .. ")")
|
|
for _ = 1, 60 do
|
|
if Music.current() == "Music_PokeFluteChannel" then break end
|
|
U.wait(1)
|
|
end
|
|
assert(Music.current() == "Music_PokeFluteChannel",
|
|
"the POKe FLUTE channel is not playing")
|
|
U.log("tuned 20.0: the POKe FLUTE channel is playing")
|
|
|
|
-- B off the card, B out of the gear, B out of the menu: the song must
|
|
-- survive all three (ExitPokegearRadio_HandleMusic keeps a tuned song).
|
|
U.tap(game, "b") U.wait(3)
|
|
U.tap(game, "b") U.wait(3)
|
|
for _ = 1, 60 do
|
|
if not topIs("Gen2StartMenu") then break end
|
|
U.tap(game, "b")
|
|
U.wait(2)
|
|
end
|
|
U.wait(5)
|
|
assert(Music.current() == "Music_PokeFluteChannel",
|
|
"the song did not survive closing the gear (playing "
|
|
.. tostring(Music.current()) .. ")")
|
|
assert(Music.mapSong() == "Music_PokeFluteChannel",
|
|
"the song did not become the map music")
|
|
U.log("gear closed: the POKe FLUTE channel persists as the map music")
|
|
|
|
-- A on the Snorlax. SnorlaxAwake hears the flute channel, and the script
|
|
-- runs on into `loadwildmon SNORLAX, 50` and `startbattle`.
|
|
U.tap(game, "a")
|
|
local battle
|
|
for _ = 1, 300 do
|
|
battle = topIs("Gen2BattleTransition") or topIs("Gen2BattleState")
|
|
if battle then break end
|
|
U.tap(game, "a")
|
|
U.wait(3)
|
|
end
|
|
assert(battle, "the Snorlax did not wake: no battle started")
|
|
-- Ride the wipe into the battle screen and read the enemy off it.
|
|
local state
|
|
for _ = 1, 600 do
|
|
state = topIs("Gen2BattleState")
|
|
if state then break end
|
|
U.wait(1)
|
|
end
|
|
assert(state, "the transition never handed over to the battle screen")
|
|
local enemy = state.battle and state.battle.enemy
|
|
assert(enemy and enemy.species == "SNORLAX",
|
|
"expected SNORLAX, got " .. tostring(enemy and enemy.species))
|
|
assert(enemy.level == 50, "expected L50, got " .. tostring(enemy.level))
|
|
-- BATTLETYPE_FORCEITEM: InitEnemyMon hands Item1 over unconditionally.
|
|
assert(enemy.item ~= nil, "the forced held item is missing")
|
|
U.log(("SNORLAX woke up: L%d battle fired, holding %s")
|
|
:format(enemy.level, tostring(enemy.item)))
|
|
|
|
print("[driver] PASS gold radio persistence + Snorlax wake")
|
|
love.event.quit()
|
|
end
|