mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 04:31:09 +02:00
@@ -0,0 +1,50 @@
|
||||
-- The bike shop's "A shiny new BICYCLE!" is six hidden_event rows, not a
|
||||
-- bg_event: data/events/hidden_events.asm:542-549 points every one of them
|
||||
-- at PrintNewBikeText (engine/events/hidden_events/new_bike.asm:1), which
|
||||
-- tx_pre_jumps NewBicycleText with ANY_FACING and no gating. The port's
|
||||
-- field extractor lifts none of that family, so BIKE_SHOP had no display
|
||||
-- text at all (#1530).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
|
||||
local pushed
|
||||
package.loaded["src.render.TextBox"] = {
|
||||
new = function(_, text, onDone) return { text = text, onDone = onDone } end,
|
||||
}
|
||||
|
||||
local scripts = require("data.scripts.flavor.bike_shop")
|
||||
local onInteract = scripts.BIKE_SHOP.onInteract
|
||||
T.check(type(onInteract) == "function", "BIKE_SHOP carries an onInteract hook")
|
||||
|
||||
local game = {
|
||||
data = { text = { _NewBicycleText = "A shiny new\nBICYCLE!" } },
|
||||
stack = { push = function(_, box) pushed = box end },
|
||||
}
|
||||
|
||||
-- data/events/hidden_events.asm:543-548 (the macro emits y then x, so the
|
||||
-- source pairs read x, y)
|
||||
for _, cell in ipairs({ { 1, 0 }, { 2, 1 }, { 1, 2 }, { 3, 2 }, { 0, 4 }, { 1, 5 } }) do
|
||||
pushed = nil
|
||||
local consumed = onInteract(game, {}, cell[1], cell[2])
|
||||
T.eq(consumed, true, ("(%d,%d) is a display tile"):format(cell[1], cell[2]))
|
||||
T.check(pushed ~= nil and pushed.text == game.data.text._NewBicycleText,
|
||||
("(%d,%d) prints _NewBicycleText"):format(cell[1], cell[2]))
|
||||
end
|
||||
|
||||
-- data/generated/maps.lua BIKE_SHOP object_events sit at (6,2), (5,6) and
|
||||
-- (1,3): none of the six, so the hook never steals an NPC's talk
|
||||
for _, cell in ipairs({ { 4, 4 }, { 6, 2 }, { 5, 6 }, { 1, 3 }, { 0, 0 } }) do
|
||||
pushed = nil
|
||||
local consumed = onInteract(game, {}, cell[1], cell[2])
|
||||
T.eq(consumed, false, ("(%d,%d) is not a display tile"):format(cell[1], cell[2]))
|
||||
T.eq(pushed, nil, "and pushes nothing")
|
||||
end
|
||||
|
||||
-- with no cache text the hook still prints the line
|
||||
pushed = nil
|
||||
onInteract({ data = {}, stack = game.stack }, {}, 1, 0)
|
||||
T.check(pushed ~= nil and pushed.text:find("BICYCLE", 1, true) ~= nil,
|
||||
"a dataset without the label falls back to the engine wording")
|
||||
|
||||
T.finish("bike shop display text (#1530)")
|
||||
@@ -146,12 +146,34 @@ T.eq(resumed, 1, "the script resumed once")
|
||||
|
||||
-- ------------------------------------------------------------- plain gift
|
||||
-- gotText == false is the script-shows-its-own-text form (Oak's 5 POKE
|
||||
-- BALLs): nothing to hang the sound on, so it plays on the spot
|
||||
-- BALLs): the received text the script prints next carries the jingle
|
||||
-- (scripts/OaksLab.asm:1058-1062), so give_item arms it and plays nothing
|
||||
plays = {}
|
||||
Commands.give_item(ctx, "FIX_POTION", 1, false)
|
||||
T.eq(jingles(), 1, "the no-text gift still plays its jingle immediately")
|
||||
T.eq(plays[1], "item.wav", "with the plain-item sound")
|
||||
T.eq(jingles(), 0, "the no-text gift plays nothing on the spot")
|
||||
T.eq(stack:top(), nil, "and pushes no box of its own")
|
||||
T.check(ctx.textOpts and ctx.textOpts.auto and ctx.textOpts.auto.sound ~= nil,
|
||||
"the jingle is armed for the next show_text")
|
||||
|
||||
Commands.show_text(ctx, "{PLAYER} GOT\nSOMETHING!")
|
||||
local box2 = stack:top()
|
||||
T.check(getmetatable(box2) == TextBox, "the script's own received box is up")
|
||||
T.eq(ctx.textOpts, nil, "show_text consumed the armed jingle")
|
||||
for _ = 1, 2000 do
|
||||
if box2.done then break end
|
||||
step(box2.waiting and "a" or nil)
|
||||
end
|
||||
T.check(box2.done, "the received text typed out")
|
||||
T.eq(jingles(), 0, "silent until the last character is placed")
|
||||
step()
|
||||
T.eq(jingles(), 1, "the jingle fires once the text is out")
|
||||
T.eq(plays[#plays], "item.wav", "with the plain-item sound")
|
||||
step("a")
|
||||
T.eq(stack:top(), box2, "A does not close the box during the jingle")
|
||||
sources["item.wav"].playing = false
|
||||
step()
|
||||
step("a")
|
||||
T.eq(stack:top(), nil, "A closes the box after the jingle")
|
||||
|
||||
-- ------------------------------------------------------------ script data
|
||||
-- both Viridian Mart paths must hand give_item the quest text, since that
|
||||
|
||||
@@ -29,4 +29,12 @@ check(patch:find("int w_pickFileKinds", 1, true)
|
||||
check(patch:find('("GRPickerBridge.swift", ID_FILE_PICKER', 1, true),
|
||||
"iOS build patch compiles the required-import picker bridge")
|
||||
|
||||
local bootstrap = read("mobile/ios/native/GRBootstrap.m")
|
||||
check(bootstrap:find("struct utsname", 1, true)
|
||||
and bootstrap:find("SIMULATOR_MODEL_IDENTIFIER", 1, true),
|
||||
"iOS native bridge reads the hardware model on device and simulator")
|
||||
check(patch:find("int w_getDeviceModel", 1, true)
|
||||
and patch:find('{ "getDeviceModel", w_getDeviceModel }', 1, true),
|
||||
"iOS liblove patch exposes the hardware model to Lua")
|
||||
|
||||
print("ios_required_import_picker_test: ok")
|
||||
|
||||
@@ -50,20 +50,34 @@ local imp = read("src/import/RomImporter.lua")
|
||||
|
||||
check(view:find('id = "skins"', 1, true) ~= nil,
|
||||
"LauncherView registers a skins tab")
|
||||
check(view:find('id = "bug"', 1, true) ~= nil,
|
||||
"LauncherView registers a bug tab")
|
||||
check(view:find("drawSkinGlyph", 1, true) ~= nil,
|
||||
"the skins tab draws its own glyph rather than shipping an asset")
|
||||
check(view:find('assets/launcher/bug.png', 1, true) ~= nil,
|
||||
"the bug tab uses the standard bug report asset")
|
||||
-- the tab has to be next to Find, which is what the request was
|
||||
local order = view:match("local HEADER_TABS = %{(.-)%}\n")
|
||||
check(order ~= nil, "HEADER_TABS found")
|
||||
if order then
|
||||
local findAt = order:find('id = "find"', 1, true)
|
||||
local skinsAt = order:find('id = "skins"', 1, true)
|
||||
local bugAt = order:find('id = "bug"', 1, true)
|
||||
check(findAt and skinsAt and skinsAt > findAt,
|
||||
"the skins tab sits immediately after Find")
|
||||
check(skinsAt and bugAt and bugAt > skinsAt,
|
||||
"the bug tab sits after Skins")
|
||||
end
|
||||
check(view:find('imp.tab == "skins"', 1, true) ~= nil,
|
||||
"the panel dispatch routes the skins tab")
|
||||
check(view:find("buildSkinsPanel", 1, true) ~= nil, "and a panel builds it")
|
||||
check(view:find('imp.tab == "bug"', 1, true) ~= nil,
|
||||
"the panel dispatch routes the bug tab")
|
||||
check(view:find("buildBugPanel", 1, true) ~= nil, "and the bug panel builds it")
|
||||
check(view:find('Kit.toggle', 1, true) ~= nil,
|
||||
"the bug panel uses a switch for safe mode")
|
||||
check(view:find('bug-report', 1, true) ~= nil,
|
||||
"the bug panel has a report action")
|
||||
-- the panel must not offer the studio when the host did not supply it
|
||||
check(view:find("if imp.onOpenSkinStudio then", 1, true) ~= nil,
|
||||
"the Studio button is hidden without a host hook (mobile)")
|
||||
@@ -79,8 +93,15 @@ check(imp:find("_installMod", 1, true) ~= nil,
|
||||
local cycle = imp:match("local order = %{(.-)%}")
|
||||
check(cycle and cycle:find('"skins"', 1, true) ~= nil,
|
||||
"shoulder-button tab cycling reaches the skins tab")
|
||||
check(cycle and cycle:find('"bug"', 1, true) ~= nil,
|
||||
"shoulder-button tab cycling reaches the bug tab")
|
||||
local switch = imp:match("function RomImporter:_switchTab%(id%)(.-)\nend")
|
||||
check(switch and switch:find("_ensureSkins(true)", 1, true) ~= nil,
|
||||
"switching to the tab re-reads the skin list")
|
||||
check(imp:find('function RomImporter:_safeModeEnabled', 1, true) ~= nil
|
||||
and imp:find('function RomImporter:_toggleSafeMode', 1, true) ~= nil,
|
||||
"the importer owns the safe mode state")
|
||||
check(imp:find('function RomImporter:_reportIssue', 1, true) ~= nil,
|
||||
"the importer owns issue report opening")
|
||||
|
||||
T.finish("launcher_skins_tab")
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
-- engine/menus/pc.asm prints the access text between SFX_ENTER_PC and the
|
||||
-- farcall: BillsPC (:73-85) picks AccessedBillsPCText / AccessedSomeonesPCText
|
||||
-- off EVENT_MET_BILL, .playersPC (:50-59) prints AccessedMyPCText. The port
|
||||
-- opened BoxMenu / PlayerPC straight from the sound (#1529).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.load()
|
||||
|
||||
Data.text._TurnedOnPC1Text = "{PLAYER} turned on\nthe PC."
|
||||
Data.text._AccessedBillsPCText = "Accessed BILL's\nPC.\fAccessed POKéMON\nStorage System."
|
||||
Data.text._AccessedSomeonesPCText =
|
||||
"Accessed someone's\nPC.\fAccessed POKéMON\nStorage System."
|
||||
Data.text._AccessedMyPCText = "Accessed my PC.\fAccessed Item\nStorage System."
|
||||
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local OW = require("src.world.OverworldController")
|
||||
|
||||
local function setUpvalue(fn, name, val)
|
||||
local i = 1
|
||||
while true do
|
||||
local n = debug.getupvalue(fn, i)
|
||||
if not n then return false end
|
||||
if n == name then debug.setupvalue(fn, i, val); return true end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
local pushed, screens = {}, {}
|
||||
local stackStub = { push = function(_, item) pushed[#pushed + 1] = item end }
|
||||
local textBoxStub = {
|
||||
new = function(_, text, onDone, opts)
|
||||
return { kind = "text", text = text, onDone = onDone, opts = opts }
|
||||
end,
|
||||
}
|
||||
local menuStub = {
|
||||
new = function(_, items, opts) return { kind = "menu", items = items, opts = opts or {} } end,
|
||||
}
|
||||
package.loaded["src.core.Sound"] = { play = function() end, playCry = function() end }
|
||||
package.loaded["src.ui.Menu"] = menuStub
|
||||
|
||||
local fakeGame = { data = Data, save = SaveData.newGame(), stack = stackStub }
|
||||
T.check(setUpvalue(OW.openPC, "Game", fakeGame), "Game upvalue on openPC")
|
||||
T.check(setUpvalue(OW.openPC, "TextBox", textBoxStub), "TextBox upvalue on openPC")
|
||||
T.check(setUpvalue(OW.openPC, "Screens",
|
||||
{ push = function(_, id) screens[#screens + 1] = id end }), "Screens upvalue on openPC")
|
||||
|
||||
local fakeSelf = setmetatable({}, { __index = OW })
|
||||
|
||||
local function openMenu(metBill)
|
||||
pushed, screens = {}, {}
|
||||
fakeGame.save = SaveData.newGame()
|
||||
if metBill then fakeGame.save.flags.EVENT_MET_BILL = true end
|
||||
fakeSelf:openPC(function() end)
|
||||
local pcOn = pushed[#pushed]
|
||||
T.eq(pcOn.kind, "text", "the session opens with TurnedOnPC1Text")
|
||||
pcOn.onDone()
|
||||
local menu = pushed[#pushed]
|
||||
T.eq(menu.kind, "menu", "then the PC menu")
|
||||
return menu
|
||||
end
|
||||
|
||||
-- === SOMEONE'S PC: the access text before BoxMenu
|
||||
do
|
||||
local menu = openMenu(false)
|
||||
menu.items[1].onSelect()
|
||||
local box = pushed[#pushed]
|
||||
T.eq(box.kind, "text", "the box row opens a text box")
|
||||
T.check(tostring(box.text):find("Accessed someone's", 1, true) ~= nil,
|
||||
"before meeting BILL it is AccessedSomeonesPCText")
|
||||
T.eq(#screens, 0, "and the box screen has NOT opened yet")
|
||||
box.onDone()
|
||||
T.eq(screens[1], "BoxMenu", "BoxMenu follows the text, as the farcall does")
|
||||
end
|
||||
|
||||
-- === BILL'S PC once EVENT_MET_BILL is set
|
||||
do
|
||||
local menu = openMenu(true)
|
||||
menu.items[1].onSelect()
|
||||
local box = pushed[#pushed]
|
||||
T.check(tostring(box.text):find("Accessed BILL's", 1, true) ~= nil,
|
||||
"after meeting BILL it is AccessedBillsPCText")
|
||||
box.onDone()
|
||||
T.eq(screens[1], "BoxMenu", "and still opens BoxMenu")
|
||||
end
|
||||
|
||||
-- === the player's item storage
|
||||
do
|
||||
local menu = openMenu(false)
|
||||
menu.items[2].onSelect()
|
||||
local box = pushed[#pushed]
|
||||
T.eq(box.kind, "text", "the item row opens a text box")
|
||||
T.check(tostring(box.text):find("Accessed my PC.", 1, true) ~= nil,
|
||||
"and it is AccessedMyPCText")
|
||||
T.eq(#screens, 0, "PlayerPC has not opened yet")
|
||||
box.onDone()
|
||||
T.eq(screens[1], "PlayerPC", "PlayerPC follows the text")
|
||||
end
|
||||
|
||||
T.finish("PC access text (#1529)")
|
||||
@@ -0,0 +1,152 @@
|
||||
-- A landed secondary POISON runs PoisonEffect's tail
|
||||
-- (engine/battle/effects.asm:119-151): SHAKE_SCREEN_ANIM when the foe
|
||||
-- poisoned you, ENEMY_HUD_SHAKE_ANIM when you poisoned the foe, through
|
||||
-- PlayBattleAnimation2 (:1461-1471), which also stamps wAnimationType 6 /
|
||||
-- 3 so the slow applying shake runs even with battle animations off.
|
||||
-- FreezeBurnParalyzeEffect (:194-255) zeroes wAnimationType and only
|
||||
-- shakes the enemy HUD on the player's turn. The port queued neither
|
||||
-- (#1526).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.fresh()
|
||||
require("src.render.Font").load(Data)
|
||||
local BattleState = require("src.battle.BattleState")
|
||||
local Pokemon = require("src.pokemon.Pokemon")
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
TypeChart.load(Data)
|
||||
|
||||
Data.moves.FIX_POISON_STING = {
|
||||
id = "FIX_POISON_STING", index = 5, name = "FIX PSN STING", type = "POISON",
|
||||
power = 15, accuracy = 100, pp = 35, effect = "POISON_SIDE_EFFECT1",
|
||||
}
|
||||
|
||||
local function newBattle()
|
||||
local save = SaveData.newGame()
|
||||
save.party = { Pokemon.new(Data, "FIXMON_A", 40) }
|
||||
local game = { data = Data, save = save,
|
||||
stack = { top = function() return nil end, push = function() end } }
|
||||
local battle = BattleState.newWild(game, "FIXMON_C", 40)
|
||||
battle.rng = function() return 0 end -- every roll lands
|
||||
return battle
|
||||
end
|
||||
|
||||
local function animRows(battle)
|
||||
local rows = {}
|
||||
for _, item in ipairs(battle.queue) do
|
||||
if item.anim then rows[#rows + 1] = item end
|
||||
end
|
||||
return rows
|
||||
end
|
||||
|
||||
local function find(rows, name)
|
||||
for i, row in ipairs(rows) do
|
||||
if row.anim == name then return i, row end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function textIndex(battle, needle)
|
||||
for i, item in ipairs(battle.queue) do
|
||||
if item.text and item.text:find(needle, 1, true) then return i end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function animIndex(battle, name)
|
||||
for i, item in ipairs(battle.queue) do
|
||||
if item.anim == name then return i end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the foe poisons you: SE_SHAKE_SCREEN plus wAnimationType 3
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.enemy, battle.player, { id = "FIX_POISON_STING", pp = 35 })
|
||||
T.eq(battle.player.mon.status, "PSN", "the secondary poison landed")
|
||||
local rows = animRows(battle)
|
||||
local i, row = find(rows, "SHAKE_SCREEN_ANIM")
|
||||
T.check(i ~= nil, "the enemy's turn queues SHAKE_SCREEN_ANIM")
|
||||
T.eq(row.attackerIsPlayer, false, "attributed to the enemy side")
|
||||
T.eq(row.hit and row.hit.animType, 3, "wAnimationType 3 rides the row")
|
||||
T.eq(row.animDelayed, true, "PlayBattleAnimationGotID pays no Delay3")
|
||||
local moveIdx = animIndex(battle, "FIX_POISON_STING")
|
||||
local shakeIdx = animIndex(battle, "SHAKE_SCREEN_ANIM")
|
||||
local textIdx = textIndex(battle, "poisoned")
|
||||
T.check(moveIdx and shakeIdx and moveIdx < shakeIdx,
|
||||
"the move animation still runs first")
|
||||
T.check(textIdx and shakeIdx < textIdx,
|
||||
"PlayBattleAnimation2 precedes PrintText (effects.asm:149-151)")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- you poison the foe: SE_SHAKE_ENEMY_HUD plus wAnimationType 6
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.player, battle.enemy, { id = "FIX_POISON_STING", pp = 35 })
|
||||
T.eq(battle.enemy.mon.status, "PSN", "the secondary poison landed")
|
||||
local _, row = find(animRows(battle), "ENEMY_HUD_SHAKE_ANIM")
|
||||
T.check(row ~= nil, "the player's turn queues ENEMY_HUD_SHAKE_ANIM")
|
||||
T.eq(row.attackerIsPlayer, true, "attributed to the player side")
|
||||
T.eq(row.hit and row.hit.animType, 6, "wAnimationType 6 rides the row")
|
||||
T.check(find(animRows(battle), "SHAKE_SCREEN_ANIM") == nil,
|
||||
"and never the enemy-side id")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- burn takes the FreezeBurnParalyzeEffect arms: HUD shake on the player's
|
||||
-- turn only, and no wAnimationType at all
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.player, battle.enemy, { id = "FIX_EMBERISH", pp = 25 })
|
||||
T.eq(battle.enemy.mon.status, "BRN", "the secondary burn landed")
|
||||
local _, row = find(animRows(battle), "ENEMY_HUD_SHAKE_ANIM")
|
||||
T.check(row ~= nil, "the player's burn shakes the enemy HUD")
|
||||
T.eq(row.hit, nil, "FreezeBurnParalyzeEffect zeroes wAnimationType")
|
||||
|
||||
local other = newBattle()
|
||||
other.queue, other.nextInsert = {}, 0
|
||||
other:performMove(other.enemy, other.player, { id = "FIX_EMBERISH", pp = 25 })
|
||||
T.eq(other.player.mon.status, "BRN", "the enemy's burn landed too")
|
||||
T.check(find(animRows(other), "ENEMY_HUD_SHAKE_ANIM") == nil,
|
||||
"the enemy's-turn arm plays nothing")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- a plain damaging move queues neither
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.player, battle.enemy, { id = "FIX_TACKLE", pp = 35 })
|
||||
local rows = animRows(battle)
|
||||
T.check(find(rows, "ENEMY_HUD_SHAKE_ANIM") == nil
|
||||
and find(rows, "SHAKE_SCREEN_ANIM") == nil,
|
||||
"no status, no PlayBattleAnimation2 row")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the residual tick plays BURN_PSN_ANIM with NO shake: core.asm:490-491
|
||||
-- explicitly zeroes wAnimationType before it
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle.player.mon.status = "PSN"
|
||||
battle:residualFor(battle.player, battle.enemy)
|
||||
local _, row = find(animRows(battle), "BURN_PSN_ANIM")
|
||||
T.check(row ~= nil, "the poison tick animates")
|
||||
T.eq(row.hit, nil, "with no applying-attack shake")
|
||||
T.eq(row.attackerIsPlayer, true, "on the hurt mon's side")
|
||||
end
|
||||
|
||||
T.finish("secondary status animation (#1526)")
|
||||
@@ -0,0 +1,94 @@
|
||||
-- JoypadOverworld calls RunMapScript every overworld frame before input is
|
||||
-- even read (home/overworld.asm:1816-1821), and the gate guards are
|
||||
-- per-frame "is the player standing on these coords" checks
|
||||
-- (scripts/Route16Gate1F.asm:16, Route5Gate.asm:19, Route22Gate.asm:21).
|
||||
-- The port only evaluated them on a completed step, so saving on a guard's
|
||||
-- tile and reloading walked past the guard (#1547).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
if not _G.love then _G.love = require("tests.love_stub") end
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.fresh()
|
||||
Data.tilesets.FIX_OUT.tilesPerRow = 16
|
||||
Data.field.flyWarps = Data.field.flyWarps or {}
|
||||
Data.field.playerSprites = { walk = "SPRITE_FIX_PLAYER" }
|
||||
Data.field.waterTilesets = {}
|
||||
Data.field.forcedMovement = { tiles = {} }
|
||||
Data.audio = Data.audio or {}
|
||||
Data.audio.songs = Data.audio.songs or {}
|
||||
Data.audio.mapSongs = Data.audio.mapSongs or {}
|
||||
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local Game = require("src.core.Game")
|
||||
local StateStack = require("src.core.StateStack")
|
||||
local OverworldState = require("src.world.OverworldController")
|
||||
local MapScripts = require("src.script.MapScripts")
|
||||
|
||||
Game.data = Data
|
||||
Game.save = SaveData.newGame()
|
||||
Game.save.player.name = "RED"
|
||||
Game.save.player.map = "FIX_TOWN"
|
||||
StateStack:init()
|
||||
Game.stack = StateStack
|
||||
Game.overworld = OverworldState
|
||||
Game.input = {
|
||||
isDown = function() return false end,
|
||||
wasPressed = function() return false end,
|
||||
step = function() end, state = {}, pressQueue = {},
|
||||
}
|
||||
Game.renderer = {
|
||||
beginWorldPass = function() end, endWorldPass = function() end,
|
||||
beginUIPass = function() end, endUIPass = function() end,
|
||||
worldViewSize = function() return 160, 144 end,
|
||||
setSGBZones = function() end,
|
||||
}
|
||||
|
||||
local TRIGGER_X, TRIGGER_Y = 4, 4
|
||||
local fired = {}
|
||||
MapScripts.attachBase("FIX_TOWN", {
|
||||
onStep = function(_, _, x, y)
|
||||
if x == TRIGGER_X and y == TRIGGER_Y then
|
||||
fired[#fired + 1] = { x, y }
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
||||
local function loadedSave()
|
||||
local save = SaveData.newGame()
|
||||
save.player.map = "FIX_TOWN"
|
||||
save.player.x, save.player.y = TRIGGER_X, TRIGGER_Y
|
||||
return save
|
||||
end
|
||||
|
||||
-- === the exploit: F2 / CONTINUE onto the guard's tile re-fires the guard
|
||||
fired = {}
|
||||
Game:restoreSave(loadedSave(), false, { freshBoot = true })
|
||||
T.eq(#fired, 1, "a freshBoot restore re-evaluates the standing-tile trigger")
|
||||
T.same(fired[1], { TRIGGER_X, TRIGGER_Y },
|
||||
"at the coords the save left the player on")
|
||||
|
||||
-- === an ordinary warp arrival must NOT fire it
|
||||
fired = {}
|
||||
OverworldState:setMap("FIX_TOWN", TRIGGER_X, TRIGGER_Y, "up", {})
|
||||
T.eq(#fired, 0, "a plain warp arrival still leaves the trigger to onStepComplete")
|
||||
|
||||
-- === dev tooling reuses opts.via == "boot" WITHOUT freshBoot
|
||||
fired = {}
|
||||
OverworldState:setMap("FIX_TOWN", TRIGGER_X, TRIGGER_Y, "up", { via = "boot" })
|
||||
T.eq(#fired, 0, "the console warp / hot reload shape does not fire it")
|
||||
|
||||
-- === checkpoint resume must never re-run map scripts
|
||||
fired = {}
|
||||
Game:restoreCheckpointSave(loadedSave())
|
||||
T.eq(#fired, 0, "a checkpoint resume re-runs nothing")
|
||||
|
||||
-- === restoring somewhere harmless fires nothing
|
||||
fired = {}
|
||||
local elsewhere = loadedSave()
|
||||
elsewhere.player.x, elsewhere.player.y = 3, 3
|
||||
Game:restoreSave(elsewhere, false, { freshBoot = true })
|
||||
T.eq(#fired, 0, "a restore off the trigger cell is untouched")
|
||||
|
||||
T.finish("standing-tile triggers on restore (#1547)")
|
||||
@@ -0,0 +1,87 @@
|
||||
-- The Nugget Bridge recruiter has no def_trainers header, so the port's
|
||||
-- headerless engageTrainer fallback re-printed his contest line as the
|
||||
-- pre-battle box (#1550) and his loss line never reached the battle
|
||||
-- screen (#1551). scripts/Route24.asm:120-134: .JoinTeamRocketText, then
|
||||
-- SaveEndBattleTextPointers with .DefeatedText, then EngageMapTrainer with
|
||||
-- no further box; Route24AfterRocketBattleScript (:62-78) prints
|
||||
-- .YouCouldBecomeATopLeaderText on the map after the win.
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.load()
|
||||
local SaveData = require("src.core.SaveData")
|
||||
|
||||
Data.items.NUGGET = Data.items.NUGGET
|
||||
or { id = "NUGGET", index = 49, name = "NUGGET", price = 10000 }
|
||||
Data.text._Route24CooltrainerM1YouBeatOurContestText =
|
||||
"Congratulations!\nYou beat our 5\ncontest trainers!"
|
||||
Data.text._Route24CooltrainerM1YouJustEarnedAPrizeText = "You just earned\na prize!"
|
||||
Data.text._Route24CooltrainerM1ReceivedNuggetText = "{PLAYER} got\n{RAM:wStringBuffer}!"
|
||||
Data.text._Route24CooltrainerM1JoinTeamRocketText = "Want to join us?"
|
||||
Data.text._Route24CooltrainerM1DefeatedText = "Arrgh!\nYou are good!"
|
||||
Data.text._Route24CooltrainerM1YouCouldBecomeATopLeaderText =
|
||||
"With your ability,\nyou could become\na top leader!"
|
||||
|
||||
local pushed = {}
|
||||
package.loaded["src.render.TextBox"] = {
|
||||
new = function(_, text, onDone, opts)
|
||||
return { text = text, onDone = onDone, opts = opts }
|
||||
end,
|
||||
substitute = function(_, s) return s end,
|
||||
soundOpts = function(_, sound, opts)
|
||||
opts = opts or {}
|
||||
opts.auto = { sound = sound, wait = true, delay = 0 }
|
||||
return opts
|
||||
end,
|
||||
}
|
||||
|
||||
local scripts = dofile("data/scripts/story4.lua")
|
||||
local handler = scripts.ROUTE_24.talk.TEXT_ROUTE24_COOLTRAINER_M1
|
||||
T.check(type(handler) == "function", "the recruiter has a hand-ported handler")
|
||||
|
||||
local game = {
|
||||
data = Data,
|
||||
save = SaveData.newGame(),
|
||||
stack = { push = function(_, box) pushed[#pushed + 1] = box end },
|
||||
}
|
||||
|
||||
local defeated = false
|
||||
local engaged
|
||||
local ow = {
|
||||
trainerDefeated = function() return defeated end,
|
||||
engageTrainer = function(_, npc, onDone, endBattleText, skipBattleText)
|
||||
engaged = { npc = npc, onDone = onDone,
|
||||
endBattleText = endBattleText, skipBattleText = skipBattleText }
|
||||
end,
|
||||
}
|
||||
local npc = { id = "ROUTE24_ROCKET", def = { index = 1 } }
|
||||
|
||||
-- the prize has already been taken: the talk goes straight to the battle
|
||||
game.save.flags.EVENT_GOT_NUGGET = true
|
||||
local doneCalls = 0
|
||||
handler(game, ow, npc, function() doneCalls = doneCalls + 1 end)
|
||||
|
||||
T.check(engaged ~= nil, "the recruiter engages")
|
||||
T.eq(#pushed, 0, "no text box is pushed before the battle (#1550)")
|
||||
T.eq(engaged.skipBattleText, true,
|
||||
"skipBattleText stops the map text becoming the pre-battle box")
|
||||
T.eq(engaged.endBattleText, Data.text._Route24CooltrainerM1DefeatedText,
|
||||
"the loss line rides the battle, as SaveEndBattleTextPointers does (#1551)")
|
||||
|
||||
-- the win: Route24AfterRocketBattleScript prints the top-leader line
|
||||
defeated = true
|
||||
engaged.onDone()
|
||||
T.eq(#pushed, 1, "the win prints exactly one box")
|
||||
T.eq(pushed[1].text, Data.text._Route24CooltrainerM1YouCouldBecomeATopLeaderText,
|
||||
"and it is .YouCouldBecomeATopLeaderText")
|
||||
pushed[1].onDone()
|
||||
T.eq(doneCalls, 1, "control returns once the box closes")
|
||||
|
||||
-- the blackout arm: wIsInBattle == $ff rets before the DisplayTextID
|
||||
pushed, defeated, doneCalls = {}, false, 0
|
||||
handler(game, ow, npc, function() doneCalls = doneCalls + 1 end)
|
||||
engaged.onDone()
|
||||
T.eq(#pushed, 0, "a loss prints nothing")
|
||||
T.eq(doneCalls, 1, "and just unfreezes the player")
|
||||
|
||||
T.finish("Nugget Bridge Rocket battle text (#1550, #1551)")
|
||||
@@ -41,7 +41,8 @@ _G.love = {
|
||||
getVersion = function() return 12, 0, 0, "Mysterious Mysteries" end,
|
||||
system = {
|
||||
getOS = function() return "iOS" end,
|
||||
getModel = function() return "iPad Test" end,
|
||||
getDeviceModel = function() return "iPhone16,2" end,
|
||||
getModel = function() return "Apple A17 Pro GPU" end,
|
||||
openURL = function(url) openedURL = url end,
|
||||
},
|
||||
graphics = {
|
||||
@@ -78,10 +79,13 @@ check(not url:find("game=", 1, true)
|
||||
check(fields.summary == "" and fields.location == "" and fields.screenshot == ""
|
||||
and fields.steps == "" and fields.expected == "",
|
||||
"report leaves user-entered fields blank")
|
||||
check(info.metadata:find("Device: iPad Test", 1, true) ~= nil
|
||||
check(info.device == "iPhone 15 Pro Max"
|
||||
and info.metadata:find("Device: iPhone 15 Pro Max", 1, true) ~= nil
|
||||
and info.metadata:find("LÖVE: 12.0.0", 1, true) ~= nil
|
||||
and info.metadata:find("Safe mode: on", 1, true) ~= nil,
|
||||
"report metadata includes device and app details")
|
||||
check(not info.metadata:find("Simulator GPU", 1, true),
|
||||
"report metadata does not mistake the renderer device for the device")
|
||||
check(not info.metadata:find("unknown", 1, true),
|
||||
"report metadata omits unknown values")
|
||||
check(not info.metadata:find("Game id", 1, true)
|
||||
@@ -104,25 +108,31 @@ check(not developmentInfo.metadata:find("0.0.0-dev", 1, true),
|
||||
|
||||
local previousOS = love.system.getOS
|
||||
local previousModel = love.system.getModel
|
||||
local previousDeviceModel = love.system.getDeviceModel
|
||||
local previousIO = _G.io
|
||||
love.system.getOS = function() return "OS X" end
|
||||
love.system.getModel = nil
|
||||
love.system.getDeviceModel = nil
|
||||
_G.io = {
|
||||
popen = function()
|
||||
popen = function(command)
|
||||
local output = command:find("system_profiler", 1, true)
|
||||
and "Hardware Overview:\n Model Name: MacBook Air\n Model Identifier: Mac14,15\n Chip: Apple M2\n"
|
||||
or "Mac14,15\n"
|
||||
return {
|
||||
read = function() return "MacBookPro18,3" end,
|
||||
read = function() return output end,
|
||||
close = function() end,
|
||||
}
|
||||
end,
|
||||
}
|
||||
local desktopInfo = IssueReport.metadata({}, { mods = {} })
|
||||
check(desktopInfo.device == "MacBookPro18,3",
|
||||
check(desktopInfo.device == "MacBook Air (Apple M2)",
|
||||
"report finds desktop device model when LOVE has no model")
|
||||
love.system.getOS = function() return "UWP" end
|
||||
local xboxInfo = IssueReport.metadata({}, { mods = {} })
|
||||
check(xboxInfo.os == "Xbox", "report maps the Xbox runtime platform")
|
||||
love.system.getOS = previousOS
|
||||
love.system.getModel = previousModel
|
||||
love.system.getDeviceModel = previousDeviceModel
|
||||
_G.io = previousIO
|
||||
|
||||
local opened = IssueReport.open({ safeMode = false }, {
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
-- SwitchPlayerMon (engine/battle/core.asm:2419-2423) prints RetreatMon and
|
||||
-- holds 50 frames BEFORE the outgoing pic is recalled, and only then does
|
||||
-- SendOutMon shout "Go! X!" (#1534). The port queued the send-out line
|
||||
-- alone, so the withdraw box never existed. PlayerMon2Text's adjective
|
||||
-- (engine/battle/common_text.asm:167-243) reads the ENEMY HP lost since
|
||||
-- this mon switched in, from wLastSwitchInEnemyMonHP.
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.fresh()
|
||||
require("src.render.Font").load(Data)
|
||||
local BattleState = require("src.battle.BattleState")
|
||||
local Pokemon = require("src.pokemon.Pokemon")
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local Timing = require("src.core.Timing")
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
TypeChart.load(Data)
|
||||
|
||||
local function newBattle()
|
||||
local save = SaveData.newGame()
|
||||
save.party = { Pokemon.new(Data, "FIXMON_A", 30), Pokemon.new(Data, "FIXMON_B", 30) }
|
||||
local game = { data = Data, save = save,
|
||||
stack = { top = function() return nil end, push = function() end } }
|
||||
local battle = BattleState.newWild(game, "FIXMON_C", 30)
|
||||
battle.rng = function() return 0 end
|
||||
battle.enemyAction = function() return { id = "FIX_SCRATCH", pp = 35 } end
|
||||
return battle
|
||||
end
|
||||
|
||||
-- drain the queue the way updateQueue does, recording rows in order plus
|
||||
-- who was in the player slot when each row was emitted
|
||||
local function drain(battle)
|
||||
local rows = {}
|
||||
for _ = 1, 400 do
|
||||
local item = table.remove(battle.queue, 1)
|
||||
if not item then return rows end
|
||||
rows[#rows + 1] = { text = item.text, anim = item.anim,
|
||||
auto = item.auto, autoDelay = item.autoDelay,
|
||||
playerSpecies = battle.player.mon.species }
|
||||
if item.fn then
|
||||
battle.nextInsert = 0
|
||||
item.fn()
|
||||
end
|
||||
end
|
||||
error("the queue never drained")
|
||||
end
|
||||
|
||||
local function indexOf(rows, pred)
|
||||
for i, row in ipairs(rows) do
|
||||
if pred(row) then return i end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the voluntary party-menu switch: withdraw line, then the send-out
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
drain(battle) -- the intro stamps lastSwitchInEnemyHP through sendOutText
|
||||
local outgoing = battle.player.mon.species
|
||||
local oldNick = battle.player.name
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:resolveSwitch(battle.game.save.party[2])
|
||||
local rows = drain(battle)
|
||||
|
||||
local wIdx = indexOf(rows, function(r)
|
||||
return r.text and r.text:find("Come back!", 1, true) ~= nil
|
||||
end)
|
||||
T.check(wIdx ~= nil, "the withdraw line is queued")
|
||||
T.eq(rows[wIdx].text, oldNick .. " enough!\nCome back!",
|
||||
"an untouched foe gives the `enough!` variant")
|
||||
T.eq(rows[wIdx].auto, true, "the page ends `done`, so it never waits on A")
|
||||
T.eq(rows[wIdx].autoDelay, Timing.SWITCH_PLAYER_MON,
|
||||
"it holds the 50 frames DelayFrames pays (core.asm:2421-2422)")
|
||||
T.eq(rows[wIdx].playerSpecies, outgoing,
|
||||
"the outgoing mon is still in the slot while the line prints")
|
||||
|
||||
local sIdx = indexOf(rows, function(r)
|
||||
return r.text and r.text:find("! ", 1, true) and r.text:find("Come back!", 1, true) == nil
|
||||
end)
|
||||
T.check(sIdx ~= nil and sIdx > wIdx, "the send-out shout follows the withdraw line")
|
||||
T.eq(rows[sIdx].auto, true, "the send-out page ends `done` too (#1472)")
|
||||
T.neq(rows[sIdx].playerSpecies, outgoing, "the swap happened between the two")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the adjective branches on enemy HP lost since the switch-in
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
drain(battle)
|
||||
local nick = battle.player.name
|
||||
local max = battle.enemy.mon.stats.hp
|
||||
local quarter = math.floor(max / 4)
|
||||
local function withdrawAt(dropPercent)
|
||||
battle.lastSwitchInEnemyHP = max
|
||||
battle.enemy.mon.hp = max - math.floor(dropPercent * quarter / 25)
|
||||
return battle:withdrawText(nick)
|
||||
end
|
||||
T.eq(withdrawAt(0), nick .. " enough!\nCome back!", "no damage -> `enough!`")
|
||||
T.eq(withdrawAt(50), nick .. " OK!\nCome back!", "30-69 -> `OK!`")
|
||||
T.eq(withdrawAt(80), nick .. " good!\nCome back!", "70+ -> `good!`")
|
||||
T.eq(withdrawAt(10), nick .. " \nCome back!", "1-29 -> no adjective at all")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- ChooseNextMon (core.asm:1086-1128) calls SendOutMon with NO RetreatMon
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
drain(battle)
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle.player.mon.hp = 0
|
||||
battle:openReplacementMenu()
|
||||
local rows = drain(battle)
|
||||
T.check(indexOf(rows, function(r)
|
||||
return r.text and r.text:find("Come back!", 1, true) ~= nil
|
||||
end) == nil, "the post-faint replacement prints no withdraw line")
|
||||
end
|
||||
|
||||
T.finish("switch withdraw text (#1534)")
|
||||
@@ -0,0 +1,109 @@
|
||||
-- THRASH/PETAL DANCE is a SpecialEffectsCont entry
|
||||
-- (data/battle/special_effects.asm:22), so on the SETUP turn only,
|
||||
-- engine/battle/core.asm:3129-3133 runs ThrashPetalDanceEffect before
|
||||
-- damage; it ends in PlayBattleAnimation2 with SHRINKING_SQUARE_ANIM
|
||||
-- (ANIM_B1 on the enemy's turn) plus the slow horizontal screen shake
|
||||
-- (engine/battle/effects.asm:791-808, :1461-1471). The port queued only
|
||||
-- the move's own animation (#1532).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.fresh()
|
||||
require("src.render.Font").load(Data)
|
||||
local BattleState = require("src.battle.BattleState")
|
||||
local Pokemon = require("src.pokemon.Pokemon")
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
TypeChart.load(Data)
|
||||
|
||||
Data.moves.FIX_THRASH = {
|
||||
id = "FIX_THRASH", index = 91, name = "FIX THRASH", type = "NORMAL",
|
||||
power = 90, accuracy = 100, pp = 20, effect = "THRASH_PETAL_DANCE_EFFECT",
|
||||
}
|
||||
|
||||
local function newBattle()
|
||||
local save = SaveData.newGame()
|
||||
save.party = { Pokemon.new(Data, "FIXMON_A", 40) }
|
||||
local game = { data = Data, save = save,
|
||||
stack = { top = function() return nil end, push = function() end } }
|
||||
local battle = BattleState.newWild(game, "FIXMON_C", 40)
|
||||
battle.rng = function(a) if a then return a end return 0 end
|
||||
return battle
|
||||
end
|
||||
|
||||
local function animRows(battle)
|
||||
local rows = {}
|
||||
for _, item in ipairs(battle.queue) do
|
||||
if item.anim then
|
||||
rows[#rows + 1] = { anim = item.anim, hit = item.hit,
|
||||
attackerIsPlayer = item.attackerIsPlayer }
|
||||
end
|
||||
end
|
||||
return rows
|
||||
end
|
||||
|
||||
local function indexOf(rows, name)
|
||||
for i, row in ipairs(rows) do
|
||||
if row.anim == name then return i end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the player's setup turn: the effect animation precedes the move's own
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
local slot = { id = "FIX_THRASH", pp = 20 }
|
||||
battle:performMove(battle.player, battle.enemy, slot)
|
||||
local rows = animRows(battle)
|
||||
local setup = indexOf(rows, "SHRINKING_SQUARE_ANIM")
|
||||
local move = indexOf(rows, "FIX_THRASH")
|
||||
T.check(setup ~= nil, "the setup turn queues SHRINKING_SQUARE_ANIM")
|
||||
T.check(move ~= nil and setup < move,
|
||||
"it plays BEFORE PlayPlayerMoveAnimation, as SpecialEffectsCont runs first")
|
||||
T.eq(rows[setup].attackerIsPlayer, true, "on the player's side")
|
||||
T.eq(rows[setup].hit and rows[setup].hit.animType, 6,
|
||||
"wAnimationType 6 -> ShakeScreenHorizontallySlow2 on the player's turn")
|
||||
|
||||
-- the continuation turn never reaches the effect (.ThrashingAboutCheck,
|
||||
-- core.asm:3532-3550 jumps straight to PlayerCalcMoveDamage)
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.player, battle.enemy, slot)
|
||||
T.check(indexOf(animRows(battle), "SHRINKING_SQUARE_ANIM") == nil,
|
||||
"a locked-in Thrash queues no setup animation")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the enemy's turn takes ANIM_B1 and wAnimationType 3
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:performMove(battle.enemy, battle.player, { id = "FIX_THRASH", pp = 20 })
|
||||
local rows = animRows(battle)
|
||||
local setup = indexOf(rows, "ANIM_B1")
|
||||
T.check(setup ~= nil, "the enemy's setup turn queues ANIM_B1")
|
||||
T.eq(rows[setup].attackerIsPlayer, false, "on the enemy's side")
|
||||
T.eq(rows[setup].hit and rows[setup].hit.animType, 3,
|
||||
"wAnimationType 3 -> ShakeScreenHorizontallySlow on the enemy's turn")
|
||||
T.check(indexOf(rows, "SHRINKING_SQUARE_ANIM") == nil,
|
||||
"and never the player-side id")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- a missed setup turn still runs the effect (it precedes MoveHitTest)
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle.accuracyRoll = function() return false end
|
||||
battle:performMove(battle.player, battle.enemy, { id = "FIX_THRASH", pp = 20 })
|
||||
local rows = animRows(battle)
|
||||
T.check(indexOf(rows, "SHRINKING_SQUARE_ANIM") ~= nil,
|
||||
"the setup animation survives a miss")
|
||||
T.check(indexOf(rows, "FIX_THRASH") == nil, "while the move's own anim is cancelled")
|
||||
end
|
||||
|
||||
T.finish("thrash setup animation (#1532)")
|
||||
@@ -0,0 +1,120 @@
|
||||
-- _TrainerSentOutText (data/text/text_2.asm:923) and the
|
||||
-- Go!/Do it!/Get'm! chain ending in _PlayerMon1Text (:1274-1294) end in
|
||||
-- `done`, not `prompt`: PrintText returns and the flow runs straight into
|
||||
-- AnimateSendingOutMon + PlayCry (engine/battle/core.asm:1421-1434,
|
||||
-- :1723-1765). _AIBattleWithdrawText (:1-7) does end in `prompt` and
|
||||
-- keeps its button wait. The port made every send-out box wait (#1472).
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
local Data = T.fixtures.fresh()
|
||||
require("src.render.Font").load(Data)
|
||||
local BattleState = require("src.battle.BattleState")
|
||||
local Pokemon = require("src.pokemon.Pokemon")
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
TypeChart.load(Data)
|
||||
|
||||
local function newBattle()
|
||||
local save = SaveData.newGame()
|
||||
save.party = { Pokemon.new(Data, "FIXMON_A", 30), Pokemon.new(Data, "FIXMON_B", 30) }
|
||||
local game = { data = Data, save = save,
|
||||
stack = { top = function() return nil end, push = function() end } }
|
||||
local battle = BattleState.newWild(game, "FIXMON_C", 30)
|
||||
battle.rng = function() return 0 end
|
||||
battle.enemyAction = function() return { id = "FIX_SCRATCH", pp = 35 } end
|
||||
return battle
|
||||
end
|
||||
|
||||
local function rowWith(battle, needle)
|
||||
for _, item in ipairs(battle.queue) do
|
||||
if item.text and item.text:find(needle, 1, true) then return item end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the voluntary switch: the shout auto-continues into the send-out anim
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:resolveSwitch(battle.game.save.party[2])
|
||||
-- run the first act so the nested switch rows land in the queue
|
||||
local first = table.remove(battle.queue, 1)
|
||||
battle.nextInsert = 0
|
||||
first.fn()
|
||||
local withdraw = rowWith(battle, "Come back!")
|
||||
T.check(withdraw ~= nil, "the withdraw line is queued")
|
||||
T.eq(withdraw.auto, true, "RetreatMon's page ends `done` (#1534)")
|
||||
local swap = table.remove(battle.queue, 2)
|
||||
battle.nextInsert = 1
|
||||
swap.fn()
|
||||
local shout = rowWith(battle, battle.player.name)
|
||||
T.check(shout ~= nil, "the send-out shout is queued")
|
||||
T.eq(shout.auto, true, "_PlayerMon1Text ends `done`, so no button wait")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the AI switch: the sent-out box goes auto, the withdraw box does not,
|
||||
-- and EnemySendOut's grow-in + cry now follow it
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local save = SaveData.newGame()
|
||||
save.party = { Pokemon.new(Data, "FIXMON_A", 30) }
|
||||
local game = { data = Data, save = save,
|
||||
stack = { top = function() return nil end, push = function() end } }
|
||||
local battle = BattleState.newTrainer(game, "OPP_FIX_YOUNGSTER", 1)
|
||||
battle.rng = function() return 0 end
|
||||
battle.enemyParty = { Pokemon.new(Data, "FIXMON_B", 30),
|
||||
Pokemon.new(Data, "FIXMON_C", 30) }
|
||||
battle.enemyIndex = 1
|
||||
battle.enemy = battle.enemy or nil
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle:executeAction(battle.enemy, battle.player,
|
||||
{ special = "aiSwitch", index = 2 })
|
||||
local withdrew = rowWith(battle, "with-")
|
||||
local sent = rowWith(battle, "sent")
|
||||
T.check(withdrew ~= nil, "the AI withdraw line is queued")
|
||||
T.eq(withdrew.auto, nil, "_AIBattleWithdrawText ends `prompt` and still waits")
|
||||
T.check(sent ~= nil, "the sent-out line is queued")
|
||||
T.eq(sent.auto, true, "_TrainerSentOutText ends `done`")
|
||||
T.eq(battle.enemySendingOut, true,
|
||||
"the new pic stays hidden until AnimateSendingOutMon")
|
||||
local acts = 0
|
||||
for _, item in ipairs(battle.queue) do
|
||||
if item.fn then acts = acts + 1 end
|
||||
end
|
||||
T.check(acts >= 1, "EnemySendOut queues the grow-in act after the text")
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- the post-faint replacement (ChooseNextMon -> SendOutMon, core.asm:1124)
|
||||
-- ---------------------------------------------------------------------
|
||||
do
|
||||
local battle = newBattle()
|
||||
local pushedUI
|
||||
battle.game.stack.push = function(_, s) pushedUI = s end
|
||||
battle.queue, battle.nextInsert = {}, 0
|
||||
battle.player.mon.hp = 0
|
||||
battle:openReplacementMenu()
|
||||
local onSwitch
|
||||
for _, item in ipairs(battle.queue) do
|
||||
if item.ui then
|
||||
local screen = item.ui()
|
||||
onSwitch = screen and screen.onSwitch
|
||||
end
|
||||
end
|
||||
onSwitch = onSwitch or (pushedUI and pushedUI.onSwitch)
|
||||
if onSwitch then
|
||||
battle.nextInsert = 0
|
||||
onSwitch(battle.game.save.party[2])
|
||||
local shout = rowWith(battle, battle.player.name)
|
||||
T.check(shout ~= nil, "the replacement shout is queued")
|
||||
T.eq(shout.auto, true, "SendOutMon's message ends `done` here too")
|
||||
else
|
||||
T.check(false, "the replacement menu offers an onSwitch callback")
|
||||
end
|
||||
end
|
||||
|
||||
T.finish("trainer send-out boxes (#1472)")
|
||||
Reference in New Issue
Block a user