mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-06 17:10:55 -04:00
72f2294d8d
CLOSES #2649, CLOSES #2650, CLOSES #2652, CLOSES #2653, CLOSES #2654, CLOSES #2657, CLOSES #2658, CLOSES #2659, CLOSES #2660, CLOSES #2662, CLOSES #2664, CLOSES #2665, CLOSES #2666, CLOSES #2669, CLOSES #2671, CLOSES #2672, CLOSES #2674, CLOSES #2676, CLOSES #2682, CLOSES #2683, CLOSES #2684, CLOSES #2685, CLOSES #2686, CLOSES #2687, CLOSES #2688, CLOSES #2689
63 lines
1.8 KiB
Lua
63 lines
1.8 KiB
Lua
-- engine/events/hidden_events/indigo_plateau_statues.asm:5
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
|
|
local T = require("tests.modkit")
|
|
|
|
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
|
|
local textBoxStub = {
|
|
new = function(_, text, onDone, opts)
|
|
return { text = text, onDone = onDone, opts = opts }
|
|
end,
|
|
}
|
|
local fakeGame = {
|
|
data = { text = {
|
|
_IndigoPlateauStatuesText1 = "PLAQUE",
|
|
_IndigoPlateauStatuesText2 = "ULTIMATE GOAL",
|
|
_IndigoPlateauStatuesText3 = "HIGHEST AUTHORITY",
|
|
} },
|
|
stack = { push = function(_, box) pushed = box end },
|
|
}
|
|
T.check(setUpvalue(OW.tryBookshelf, "TextBox", textBoxStub),
|
|
"TextBox upvalue on tryBookshelf")
|
|
T.check(setUpvalue(OW.tryBookshelf, "Game", fakeGame),
|
|
"Game upvalue on tryBookshelf")
|
|
|
|
local map = {
|
|
def = { tileset = "PLATEAU" },
|
|
inBounds = function() return true end,
|
|
cellTile = function() return 0x30 end,
|
|
}
|
|
|
|
local function read(cellX)
|
|
pushed = nil
|
|
local self_ = setmetatable({ player = { facing = "up", cellX = cellX, cellY = 6 },
|
|
map = map }, { __index = OW })
|
|
local ok = self_:tryBookshelf(cellX, 5)
|
|
return ok, pushed and pushed.text
|
|
end
|
|
|
|
for _, x in ipairs({ 9, 11 }) do
|
|
local ok, text = read(x)
|
|
T.eq(ok, true, "odd X " .. x .. " statue is consumed")
|
|
T.eq(text, "PLAQUE\fULTIMATE GOAL", "odd X " .. x .. " prints Text2")
|
|
end
|
|
for _, x in ipairs({ 8, 10 }) do
|
|
local ok, text = read(x)
|
|
T.eq(ok, true, "even X " .. x .. " statue is consumed")
|
|
T.eq(text, "PLAQUE\fHIGHEST AUTHORITY", "even X " .. x .. " prints Text3")
|
|
end
|
|
|
|
T.finish("indigo_statues_bug2683")
|