fix(game3/battle): guard from_rom and move_target_byte against nil ROM pack in headless tests

This commit is contained in:
1jamie
2026-09-23 14:12:44 -05:00
parent ce79dc86d5
commit a366339873
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -124,8 +124,8 @@ end
local function move_target_byte(mv)
if move_num(mv) == 0 then return 0 end
local Moves = require("src.core.game3.battle.moves")
local m = Moves.get(mv)
return tonumber(m and m.target) or 0
local ok, m = pcall(Moves.get, mv)
return tonumber(ok and m and m.target) or 0
end
local function random_u16(rng)
+1
View File
@@ -116,6 +116,7 @@ end
local function from_rom(numId)
Moves.romReady()
if not Moves._rom then return nil end
local row = Moves._rom[numId]
if not row then return nil end
local cat = Types.isPhysical(row.type) and "physical" or "special"