Cover Gold's Light Screen / Reflect fix in the same test

The targeted test only covered the RBY side (ItemEffects.lua,
TrainerAI.lua); src/battle/gen2/Battle.lua's EFFECT_LIGHT_SCREEN/
EFFECT_REFLECT fix had no test at all, spotted when asked whether the
Gold changes were covered.

Adds a minimal MACHOP/TACKLE gen2 fixture (same shape as
tests/gen2_move_effects_test.lua's), calls both MOVE_EFFECTS directly,
and checks a loaded catalog reaches the whole message template (Gold
wraps the full sentence, not just the stat name). Confirmed it catches
the regression: reverting Battle.lua to its pre-fix state fails 2 of
the suite's now 8 checks.
This commit is contained in:
thibautbus
2026-08-16 21:53:30 +02:00
parent d6ddf23f97
commit 467566c799
@@ -1,12 +1,13 @@
-- The stat name substituted into X-item/vitamin "rose!" messages must
-- itself reach a translation catalog, not just the surrounding sentence
-- template (src/inventory/ItemEffects.lua, src/battle/TrainerAI.lua).
-- With no catalog loaded it stays English (the existing baseline); with
-- one loaded that translates e.g. "ATTACK", the substituted word must
-- change too -- that is the actual bug this suite guards against, which
-- passing/failing sentences alone (as other suites already check)
-- cannot tell apart from a raw stat:upper() that was never wrapped in
-- Strings() at all.
-- The stat name substituted into X-item/vitamin "rose!" messages, and
-- Gold's whole Light Screen / Reflect "rose!" messages, must reach a
-- translation catalog, not just the surrounding sentence template (RBY:
-- src/inventory/ItemEffects.lua, src/battle/TrainerAI.lua; Gold:
-- src/battle/gen2/Battle.lua). With no catalog loaded the message stays
-- English (the existing baseline); with one loaded that translates the
-- relevant word(s), the substitution must change too -- that is the
-- actual bug this suite guards against, which passing/failing sentences
-- alone (as other suites already check) cannot tell apart from text that
-- never reached Strings() at all.
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.modkit")
@@ -70,4 +71,71 @@ withCatalog({ SPEED = "VITESSE" }, function()
"a catalog translating SPEED reaches the AI trainer's X SPEED rose! message")
end)
-- ------------------------------------------------------- Gold: Light Screen / Reflect
local Gen2Battle = require("src.battle.gen2.Battle")
local Gen2Mon = require("src.battle.gen2.Mon")
local GEN2_DATA = {
pokemon = {
MACHOP = {
id = "MACHOP", index = 66, name = "MACHOP",
baseStats = { hp = 70, attack = 80, defense = 50, speed = 35,
specialAttack = 35, specialDefense = 35 },
types = { "NORMAL", "NORMAL" }, catchRate = 180, baseExp = 75,
growthRate = "GROWTH_MEDIUM_FAST", genderRatio = 63,
levelMoves = { { level = 1, move = "TACKLE" } }, evolutions = {},
},
},
moves = {
TACKLE = { id = "TACKLE", name = "TACKLE", power = 35, type = "NORMAL",
accuracy = 95, pp = 35, effect = "EFFECT_NORMAL_HIT" },
},
type_chart = { types = { NORMAL = { id = "NORMAL", index = 0,
category = "physical" } }, matchups = {} },
items = {},
}
local perfectDvs = { attack = 15, defense = 15, speed = 15, special = 15 }
perfectDvs.hp = Gen2Mon.hpDV(perfectDvs)
local function newGen2Battle()
local player = Gen2Mon.new(GEN2_DATA, "MACHOP", 15, { dvs = perfectDvs })
player.moves = { { id = "TACKLE", pp = 35, maxPp = 35 } }
local wild = Gen2Mon.new(GEN2_DATA, "MACHOP", 15, { dvs = perfectDvs })
wild.moves = { { id = "TACKLE", pp = 35, maxPp = 35 } }
return Gen2Battle.new({ data = GEN2_DATA, party = { player }, wild = wild })
end
withCatalog({ ["%s's SPCL.DEF rose!"] = "%s voit sa DEF.SPÉ augmenter !" },
function()
local lsBattle = newGen2Battle()
Gen2Battle.MOVE_EFFECTS.EFFECT_LIGHT_SCREEN(lsBattle, lsBattle.player)
local events = lsBattle:takeEvents()
local found = false
for _, event in ipairs(events) do
if event.kind == "message"
and event.text:find("DEF.SPÉ augmenter", 1, true) then
found = true
end
end
T.check(found,
"a catalog translating Light Screen's rose! message reaches it")
end)
withCatalog({ ["%s's DEFENSE rose!"] = "%s voit sa DEFENSE augmenter !" },
function()
local refBattle = newGen2Battle()
Gen2Battle.MOVE_EFFECTS.EFFECT_REFLECT(refBattle, refBattle.player)
local events = refBattle:takeEvents()
local found = false
for _, event in ipairs(events) do
if event.kind == "message"
and event.text:find("DEFENSE augmenter", 1, true) then
found = true
end
end
T.check(found,
"a catalog translating Reflect's rose! message reaches it")
end)
T.finish("stat rise message translation")