Files
gen1recomp/tests/game3_summary_description_test.lua
T
thibautbus 7f4e54f312 Find FireRed summary descriptions by the ROM's move and ability names
SummaryData looks a move or ability description up as MOVE_<name> / ABILITY_<name>, built from the name the summary shows. A translation mod renames moves in place (the moves registry writes Pokemon._moveNames), so with one enabled the key became MOVE_<translated name>, nothing matched, and the summary and TM Case showed "---" instead of the description.

Pokemon.install now keeps a copy of the ROM's English move and ability names before any mod patches them, exposed as Pokemon.romMoveName / romAbilityName, and the description lookups use it, falling back to the name passed in when the pack has none.
2026-09-19 23:04:31 +02:00

44 lines
1.7 KiB
Lua

#!/usr/bin/env luajit
-- The summary's move and ability descriptions are keyed by the English name.
-- A translation mod renames moves and abilities in place, so the lookup has
-- to go through the ROM's own name for the number, not the name on screen.
package.path = "./?.lua;./?/init.lua;" .. package.path
love = require("tests.love_stub")
local failed = 0
local function check(cond, msg)
if not cond then
failed = failed + 1
print("[FAIL] " .. msg)
end
end
local Strings = require("src.core.Strings")
local Pokemon = require("src.core.game3.pokemon")
local SummaryData = require("src.core.game3.summary_data")
-- An installed pack a mod has renamed entries of, as Gen3Compat leaves it.
Pokemon._cache = {}
Pokemon._moveNames = { [71] = "VOL-VIE" }
Pokemon._abilityNames = { [9] = "STATIK" }
Pokemon._romMoveNames = { [71] = "ABSORB" }
Pokemon._romAbilityNames = { [9] = "STATIC" }
check(SummaryData.moveDescription(71, "VOL-VIE"):find("absorbs half", 1, true) ~= nil,
"a renamed move still finds its description")
check(SummaryData.abilityDescription(9, "STATIK") == "Paralyzes on contact.",
"a renamed ability still finds its description")
Strings.load({ strings = { ["Paralyzes on contact."] = "Paralyse au contact." } })
check(SummaryData.abilityDescription(9, "STATIK") == "Paralyse au contact.",
"the description goes through Strings()")
Strings.load({})
Pokemon._romMoveNames = nil
check(SummaryData.moveDescription(71, "ABSORB"):find("absorbs half", 1, true) ~= nil,
"without the ROM names, the name passed in is used")
print(("game3_summary_description_test: %s (%d failed)"):format(failed == 0 and "PASS" or "FAIL", failed))
if failed > 0 then os.exit(1) end