mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-26 13:33:27 -04:00
a9ce423bdc
CLOSES #1275, CLOSES #1295, CLOSES #1384, CLOSES #1628, CLOSES #1677, CLOSES #1682, CLOSES #1691, CLOSES #1813, CLOSES #1822, CLOSES #1861, CLOSES #1867, CLOSES #1868, CLOSES #1869, CLOSES #1870, CLOSES #1871, CLOSES #1872, CLOSES #1874, CLOSES #1876, CLOSES #1878, CLOSES #1880, CLOSES #1881, CLOSES #1882, CLOSES #1884, CLOSES #1885, CLOSES #1886, CLOSES #1887, CLOSES #1888, CLOSES #1889, CLOSES #1890, CLOSES #1891, CLOSES #1892, CLOSES #1893, CLOSES #1894, CLOSES #1895, CLOSES #1896, CLOSES #1899, CLOSES #1900, CLOSES #1901
151 lines
4.6 KiB
Lua
151 lines
4.6 KiB
Lua
-- engine/pokegear/pokegear.asm:2285 (#1267)
|
|
-- luajit tests/engine/gen2_pokedex_area_landmark_bug1267.lua
|
|
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
|
|
local T = require("tests.harness")
|
|
local check, eq = T.check, T.eq
|
|
love = love or require("tests.love_stub")
|
|
|
|
local Chrome = require("src.ui.gen2.Chrome")
|
|
local PokedexMenu = require("src.ui.gen2.PokedexMenu")
|
|
local Nests = require("src.core.gen2.Nests")
|
|
|
|
-- one Johto landmark (index 5), one species that nests there
|
|
local data = {
|
|
gen2Encounters = {
|
|
grass = {
|
|
ROUTE_30 = { slots = { day = { { species = "RATTATA" } } } },
|
|
},
|
|
},
|
|
gen2Maps = {
|
|
ROUTE_30 = { landmark = 5 },
|
|
},
|
|
gen2Landmarks = {
|
|
landmarks = {
|
|
LANDMARK_ROUTE_30 = { index = 5, x = 40, y = 60, name = "ROUTE 30" },
|
|
},
|
|
},
|
|
}
|
|
|
|
-- sanity: Nests.landmark itself resolves the index (never broken, per the
|
|
-- verifier) so a failure below is isolated to drawArea's own lookup
|
|
eq(Nests.landmark(data, 5) and Nests.landmark(data, 5).name, "ROUTE 30",
|
|
"Nests.landmark resolves index 5 to the ROUTE 30 record")
|
|
|
|
local function newSelf(species, region)
|
|
local seen = { texts = {}, inverted = {}, header = {}, icons = {} }
|
|
local self = setmetatable({
|
|
game = { save = { position = { map = "ROUTE_30" } } },
|
|
data = data,
|
|
mapGfx = { maps = { johto = { 1 }, kanto = { 1 } } },
|
|
areaRegion = region,
|
|
areaBlink = 0,
|
|
current = function() return { species = species or "RATTATA" } end,
|
|
monName = function() return species or "RATTATA" end,
|
|
fill = function() end,
|
|
blank = function() end,
|
|
drawTilemap = function() end,
|
|
text = function(_, str, tx, ty)
|
|
seen.texts[#seen.texts + 1] = { str = str, tx = tx, ty = ty }
|
|
end,
|
|
drawAreaHeader = function(_, title)
|
|
seen.header[#seen.header + 1] = title
|
|
end,
|
|
drawNestIcon = function(_, x, y)
|
|
seen.icons[#seen.icons + 1] = { x = x, y = y }
|
|
end,
|
|
}, { __index = PokedexMenu })
|
|
return self, seen
|
|
end
|
|
|
|
local function drawText(seen)
|
|
local out = {}
|
|
for _, t in ipairs(seen.texts) do out[#out + 1] = t.str end
|
|
return table.concat(out, "|")
|
|
end
|
|
|
|
do
|
|
local self, seen = newSelf("RATTATA", "johto")
|
|
self:drawArea()
|
|
eq(#seen.icons, 1, "the one Johto nest gets one marker")
|
|
local icon = seen.icons[1]
|
|
eq(icon and icon.x, 40 - 4, "the marker sits four pixels left of the landmark")
|
|
eq(icon and icon.y, 60 - 4, "and four pixels above it")
|
|
eq(seen.header[1], "RATTATA'S NEST", "the only string is the nest caption")
|
|
eq(drawText(seen), "", "nothing is printed in the dex's inverted font")
|
|
|
|
local blinkOff = 0
|
|
for frame = 0, 31 do
|
|
local one, s2 = newSelf("RATTATA", "johto")
|
|
one.areaBlink = frame
|
|
one:drawArea()
|
|
if #s2.icons == 0 then blinkOff = blinkOff + 1 end
|
|
end
|
|
eq(blinkOff, 16, "the marker is hidden for sixteen of every thirty-two frames")
|
|
end
|
|
|
|
do
|
|
local self, seen = newSelf("RATTATA", "kanto")
|
|
self:drawArea()
|
|
eq(#seen.icons, 0, "no Kanto nest, so nothing blinks")
|
|
eq(drawText(seen), "", "and no AREA UNKNOWN over the Kanto map")
|
|
eq(seen.header[1], "RATTATA'S NEST", "the caption stays either way")
|
|
end
|
|
|
|
do
|
|
local writes = {}
|
|
local realThrough = Chrome.printThrough
|
|
Chrome.printThrough = function(str, tx, ty)
|
|
writes[#writes + 1] = { str = str, tx = tx, ty = ty }
|
|
end
|
|
local self = newSelf("RATTATA", "johto")
|
|
self.drawAreaHeader = nil
|
|
self:drawAreaHeader("RATTATA'S NEST")
|
|
Chrome.printThrough = realThrough
|
|
eq(#writes, 1, "the caption is placed once")
|
|
eq(writes[1] and writes[1].tx, 2, "at hlcoord 2")
|
|
eq(writes[1] and writes[1].ty, 0, "on row 0")
|
|
end
|
|
|
|
local function newInput()
|
|
local input = { pressed = {} }
|
|
function input:press(button) self.pressed[button] = true end
|
|
function input:wasPressed(button)
|
|
if self.pressed[button] then
|
|
self.pressed[button] = nil
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
return input
|
|
end
|
|
|
|
do
|
|
local self = newSelf("RATTATA", nil)
|
|
self.game.save.position.map = "ROUTE_30"
|
|
eq(self:areaRegionName(), "johto",
|
|
"the page opens on Johto whatever the player is standing in")
|
|
|
|
local input = newInput()
|
|
input:press("right")
|
|
self:updateArea(input)
|
|
eq(self:areaRegionName(), "johto",
|
|
"right does nothing before the Hall of Fame")
|
|
|
|
self.game.save.hallOfFame = { count = 1 }
|
|
input:press("right")
|
|
self:updateArea(input)
|
|
eq(self:areaRegionName(), "kanto", "and swaps to Kanto once it has been rung")
|
|
|
|
input:press("left")
|
|
self:updateArea(input)
|
|
eq(self:areaRegionName(), "johto", "left always comes back")
|
|
|
|
input:press("b")
|
|
self:updateArea(input)
|
|
eq(self.view, "entry", "B returns to the entry")
|
|
end
|
|
|
|
T.finish("gen2 pokedex area landmark bug 1267")
|