mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-28 23:40:14 -04:00
3cf8c373a4
CLOSES #2923, CLOSES #2925, CLOSES #2927, CLOSES #2928, CLOSES #2929, CLOSES #2930, CLOSES #2931, CLOSES #2932, CLOSES #2933, CLOSES #2934, CLOSES #2935, CLOSES #2937, CLOSES #2940, CLOSES #2941, CLOSES #2942, CLOSES #2946, CLOSES #2947, CLOSES #2948, CLOSES #2949, CLOSES #2952, CLOSES #2953, CLOSES #2954, CLOSES #2955, CLOSES #2956, CLOSES #2963, CLOSES #2964, CLOSES #2965, CLOSES #2966, CLOSES #2968, CLOSES #2972, CLOSES #2973
145 lines
5.5 KiB
Lua
145 lines
5.5 KiB
Lua
-- 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 } }
|
|
|
|
local doneCalls = 0
|
|
local function throughPitch()
|
|
pushed, engaged, doneCalls = {}, nil, 0
|
|
game.save.flags.EVENT_GOT_NUGGET = nil
|
|
handler(game, ow, npc, function() doneCalls = doneCalls + 1 end)
|
|
for i = 1, 4 do
|
|
if pushed[i] and pushed[i].onDone then pushed[i].onDone() end
|
|
end
|
|
end
|
|
|
|
throughPitch()
|
|
T.check(engaged ~= nil, "the recruiter engages after the pitch")
|
|
T.eq(#pushed, 4, "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, 5, "the win prints exactly one box")
|
|
T.eq(pushed[5].text, Data.text._Route24CooltrainerM1YouCouldBecomeATopLeaderText,
|
|
"and it is .YouCouldBecomeATopLeaderText")
|
|
pushed[5].onDone()
|
|
T.eq(doneCalls, 1, "control returns once the box closes")
|
|
|
|
-- the blackout arm: wIsInBattle == $ff rets before the DisplayTextID
|
|
defeated = false
|
|
throughPitch()
|
|
engaged.onDone()
|
|
T.eq(#pushed, 4, "a loss prints nothing")
|
|
T.eq(doneCalls, 1, "and just unfreezes the player")
|
|
|
|
-- scripts/Route24.asm:138
|
|
pushed, engaged, doneCalls = {}, nil, 0
|
|
game.save.flags.EVENT_GOT_NUGGET = true
|
|
handler(game, ow, npc, function() doneCalls = doneCalls + 1 end)
|
|
T.eq(engaged, nil, "with the NUGGET taken he never battles again")
|
|
T.eq(pushed[1] and pushed[1].text,
|
|
Data.text._Route24CooltrainerM1YouCouldBecomeATopLeaderText,
|
|
"only the top-leader line")
|
|
|
|
-- the prize arm: scripts/Route24.asm:149-158
|
|
local GameVersion = require("src.core.GameVersion")
|
|
local savedVersion = GameVersion.current
|
|
|
|
local function runPrizeArm(version)
|
|
GameVersion.current = version
|
|
pushed, defeated, doneCalls = {}, false, 0
|
|
game.save = SaveData.newGame()
|
|
game.save.flags.EVENT_GOT_NUGGET = nil
|
|
handler(game, ow, npc, function() doneCalls = doneCalls + 1 end)
|
|
return pushed
|
|
end
|
|
|
|
local p = runPrizeArm("red")
|
|
T.eq(p[1].text, Data.text._Route24CooltrainerM1YouBeatOurContestText,
|
|
"the contest line is its own box")
|
|
T.eq(p[1].opts and p[1].opts.auto and p[1].opts.auto.sound, "Get_Item1",
|
|
"and it carries sound_get_item_1 (#2156)")
|
|
p[1].onDone()
|
|
T.eq(p[2].text, Data.text._Route24CooltrainerM1YouJustEarnedAPrizeText,
|
|
"the prize line is the second box")
|
|
T.eq(p[2].opts, nil, "with no jingle of its own (#2156)")
|
|
p[2].onDone()
|
|
T.eq(p[3].text, Data.text._Route24CooltrainerM1ReceivedNuggetText,
|
|
"then the receipt box")
|
|
T.eq(p[3].opts and p[3].opts.auto and p[3].opts.auto.sound, "Get_Item1",
|
|
"which plays sound_get_item_1 on Red")
|
|
p[3].onDone()
|
|
T.eq(p[4].text, Data.text._Route24CooltrainerM1JoinTeamRocketText,
|
|
"then the Team Rocket pitch")
|
|
|
|
local y = runPrizeArm("yellow")
|
|
T.eq(y[1].opts and y[1].opts.auto and y[1].opts.auto.sound, "Get_Item1",
|
|
"Yellow arms the contest box the same way")
|
|
y[1].onDone()
|
|
T.eq(y[2].opts, nil, "and leaves the prize box silent")
|
|
y[2].onDone()
|
|
T.eq(y[3].opts and y[3].opts.auto and y[3].opts.auto.sound, "Get_Key_Item",
|
|
"the receipt box plays sound_get_key_item on Yellow (#2156)")
|
|
|
|
GameVersion.current = savedVersion
|
|
|
|
T.finish("Nugget Bridge Rocket battle text (#1550, #1551, #2156)")
|