diff --git a/tests/engine/stat_rise_message_translation_test.lua b/tests/engine/stat_rise_message_translation_test.lua index 5b8ff08c..83b4da0c 100644 --- a/tests/engine/stat_rise_message_translation_test.lua +++ b/tests/engine/stat_rise_message_translation_test.lua @@ -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")