mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-26 13:33:27 -04:00
107 lines
3.7 KiB
Lua
107 lines
3.7 KiB
Lua
-- pokered audio/sfx/pokeflute.asm:1, engine/items/item_effects.asm:1794 (#2109)
|
|
-- POKEPORT_DRIVER=tests/drivers/snorlax_flute_bug2109_test.lua \
|
|
-- POKEPORT_IDENTITY=bug2109 POKEPORT_TOUCH=0 POKEPORT_VERSION=red love .
|
|
return function(game)
|
|
local U = dofile("tests/drivers/util.lua")
|
|
local Screens = require("src.ui.Screens")
|
|
local Bag = require("src.inventory.Bag")
|
|
local Pokemon = require("src.pokemon.Pokemon")
|
|
|
|
local pass, fail = 0, 0
|
|
local function check(label, ok)
|
|
if ok then pass = pass + 1; U.log("PASS", label)
|
|
else fail = fail + 1; U.log("FAIL", label) end
|
|
return ok
|
|
end
|
|
local function finish()
|
|
U.log(("RESULT pass=%d fail=%d"):format(pass, fail))
|
|
U.log("input is yours now")
|
|
while true do coroutine.yield() end
|
|
end
|
|
|
|
local vol = game.save.options and game.save.options.sfxVol
|
|
if vol == 0 then
|
|
U.log("sfxVol is 0; turn it up in OPTION or the ear half of this check is moot")
|
|
end
|
|
|
|
game.save.party = { Pokemon.new(game.data, "PIDGEOTTO", 30) }
|
|
Bag.add(game.save, "POKE_FLUTE", 1)
|
|
|
|
U.teleport(game, "ROUTE_12", 10, 30, "down")
|
|
U.wait(20)
|
|
local ow = game.overworld
|
|
local snorlax
|
|
for _, npc in ipairs(ow.npcs or {}) do
|
|
if npc.def and tostring(npc.def.name or ""):find("SNORLAX") then snorlax = npc end
|
|
end
|
|
if not check("ROUTE_12 has its SNORLAX", snorlax ~= nil) then finish() end
|
|
U.teleport(game, "ROUTE_12", snorlax.cellX, snorlax.cellY - 1, "down")
|
|
U.wait(20)
|
|
ow = game.overworld
|
|
|
|
local bag = Screens.push(game, "BagMenu")
|
|
U.wait(20)
|
|
local row
|
|
for i, item in ipairs(bag.items) do
|
|
if item.value == "POKE_FLUTE" then row = i end
|
|
end
|
|
if not check("the POKé FLUTE is in the bag", row ~= nil) then finish() end
|
|
bag.index = row
|
|
U.tap(game, "a")
|
|
U.wait(20)
|
|
if game.stack:top() ~= bag and not game.stack:top().isTextBox then
|
|
U.tap(game, "a")
|
|
U.wait(20)
|
|
end
|
|
|
|
local box
|
|
for _ = 1, 240 do
|
|
local top = game.stack:top()
|
|
if top and top.isTextBox then box = top break end
|
|
U.wait(1)
|
|
end
|
|
if not check("the played-flute box opened", box ~= nil) then finish() end
|
|
|
|
for _ = 1, 240 do
|
|
if box.done then break end
|
|
U.tap(game, "a")
|
|
end
|
|
check("the line typed out", box.done == true)
|
|
check("nothing has played yet", box.autoStarted ~= true and box.autoSrc == nil)
|
|
U.log("the box should read '<PLAYER> played the POKé FLUTE.' with a blinking")
|
|
U.log("arrow and NO tune yet; the map music is still going")
|
|
U.shot(game, "/tmp/shots/bug2109_prompt.png")
|
|
|
|
U.tap(game, "a")
|
|
U.wait(2)
|
|
check("the prompt was answered", box.autoPrompted == true)
|
|
if not check("the tune started", box.autoSrc ~= nil) then finish() end
|
|
local duration = box.autoSrc:getDuration()
|
|
check(("the whole tune rendered (%.2f s, want >= 9.5)"):format(duration),
|
|
duration >= 9.5)
|
|
U.log("the tune plays now, with the same box still on screen; listen for all")
|
|
U.log("13 notes and then about 2.4 s of silence before the box goes away")
|
|
|
|
local heldFrames, wokeEarly = 0, false
|
|
for _ = 1, 700 do
|
|
local playing = box.autoSrc and box.autoSrc.isPlaying and box.autoSrc:isPlaying()
|
|
if not playing then break end
|
|
heldFrames = heldFrames + 1
|
|
if game.stack:top() ~= box then wokeEarly = true break end
|
|
U.tap(game, "a")
|
|
end
|
|
check("A never cut the tune short", not wokeEarly)
|
|
check(("the tune held the box through the rest (%d frames, want >= 570)")
|
|
:format(heldFrames), heldFrames >= 570)
|
|
|
|
local woke
|
|
for _ = 1, 120 do
|
|
local top = game.stack:top()
|
|
if top and top.isTextBox and top ~= box then woke = top break end
|
|
U.wait(1)
|
|
end
|
|
check("SNORLAX woke up! follows only after the tune and its rest", woke ~= nil)
|
|
U.shot(game, "/tmp/shots/bug2109_after.png")
|
|
finish()
|
|
end
|