Merge pull request #1404 from emre155/fix/save-editor-cycle-move-safety

This commit is contained in:
bryanthaboi
2026-08-16 22:04:49 -04:00
committed by GitHub
+9 -4
View File
@@ -430,7 +430,7 @@ function Ops.setDv(S, mon, key, value)
end
function Ops.cycleMove(S, mon, slot)
if not mon then return false end
if not mon or not (S.cat and S.cat.moves and #S.cat.moves > 0) then return false end
local moves = S.cat.moves
local current = mon.moves and mon.moves[slot] and mon.moves[slot].id
local idx = 0
@@ -439,9 +439,14 @@ function Ops.cycleMove(S, mon, slot)
if id == current then idx = i break end
end
end
local nextId = moves[(idx % #moves) + 1]
MonOps.setMove(S.data, mon, slot, nextId)
return Ops.mark(S, ("Move %d set to %s"):format(slot, nextId))
for step = 1, #moves do
local nextId = moves[((idx + step - 1) % #moves) + 1]
if S.data and S.data.moves and S.data.moves[nextId] then
MonOps.setMove(S.data, mon, slot, nextId)
return Ops.mark(S, ("Move %d set to %s"):format(slot, nextId))
end
end
return false
end
function Ops.clearMove(S, mon, slot)