Commit 28785924 authored by whenmo's avatar whenmo Committed by GitHub

Merge pull request #29 from whenmo/main

fix IllegalFunctionCheck
parents 0acb55e2 0310d88c
...@@ -872,7 +872,7 @@ end ...@@ -872,7 +872,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.SpellActivate(c, m, op, cost, con) function VgD.SpellActivate(c, m, op, cost, con)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("SpellActivate") local fchk = VgF.IllegalFunctionCheck("SpellActivate", c)
if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end
-- set param -- set param
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
...@@ -1215,7 +1215,7 @@ end ...@@ -1215,7 +1215,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.QuickSpell(c, op, cost, con, tg) function VgD.QuickSpell(c, op, cost, con, tg)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("QuickSpell") local fchk = VgF.IllegalFunctionCheck("QuickSpell", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param -- set param
local condition = function(e, tp, eg, ep, ev, re, r, rp) local condition = function(e, tp, eg, ep, ev, re, r, rp)
...@@ -1242,7 +1242,7 @@ end ...@@ -1242,7 +1242,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.ContinuousSpell(c, cost, con, tg) function VgD.ContinuousSpell(c, cost, con, tg)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("ContinuousSpell") local fchk = VgF.IllegalFunctionCheck("ContinuousSpell", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) then return end
-- set param -- set param
local operation = function(e, tp, eg, ep, ev, re, r, rp) local operation = function(e, tp, eg, ep, ev, re, r, rp)
...@@ -1279,7 +1279,7 @@ end ...@@ -1279,7 +1279,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.EffectTypeTrigger(c, m, loc, typ, code, op, cost, con, tg, count, property, id) function VgD.EffectTypeTrigger(c, m, loc, typ, code, op, cost, con, tg, count, property, id)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeTrigger") local fchk = VgF.IllegalFunctionCheck("EffectTypeTrigger", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param -- set param
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
...@@ -1318,7 +1318,7 @@ end ...@@ -1318,7 +1318,7 @@ end
---@return Effect 这个效果 *回传两个效果* ---@return Effect 这个效果 *回传两个效果*
function VgD.EffectTypeTriggerWhenHitting(c, m, loc, typ, op, cost, con, tg, count, p, property, id) function VgD.EffectTypeTriggerWhenHitting(c, m, loc, typ, op, cost, con, tg, count, p, property, id)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeTriggerWhenHitting") local fchk = VgF.IllegalFunctionCheck("EffectTypeTriggerWhenHitting", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param -- set param
typ = typ or EFFECT_TYPE_SINGLE typ = typ or EFFECT_TYPE_SINGLE
...@@ -1344,7 +1344,7 @@ end ...@@ -1344,7 +1344,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.CardToG(c, m, op, cost, con) function VgD.CardToG(c, m, op, cost, con)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("CardToG") local fchk = VgF.IllegalFunctionCheck("CardToG", c)
if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end
-- set param -- set param
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
...@@ -1398,7 +1398,7 @@ end ...@@ -1398,7 +1398,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.BeRidedByCard(c, m, filter, op, cost, con, tg, id) function VgD.BeRidedByCard(c, m, filter, op, cost, con, tg, id)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("BeRidedByCard") local fchk = VgF.IllegalFunctionCheck("BeRidedByCard", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param -- set param
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
...@@ -1468,7 +1468,7 @@ end ...@@ -1468,7 +1468,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.EffectTypeIgnition(c, m, loc, op, cost, con, tg, count, property, id) function VgD.EffectTypeIgnition(c, m, loc, op, cost, con, tg, count, property, id)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeIgnition") local fchk = VgF.IllegalFunctionCheck("EffectTypeIgnition", c)
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param -- set param
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
...@@ -1507,7 +1507,7 @@ end ...@@ -1507,7 +1507,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.EffectTypeContinuous(c, m, loc, typ, code, val, con, tg, loc_self, loc_op, reset, hc) function VgD.EffectTypeContinuous(c, m, loc, typ, code, val, con, tg, loc_self, loc_op, reset, hc)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeContinuous") local fchk = VgF.IllegalFunctionCheck("EffectTypeContinuous", c)
if fchk.con(con) or fchk.tg(tg) then return end if fchk.con(con) or fchk.tg(tg) then return end
-- set param -- set param
local cm = _G["c"..(m or c:GetOriginalCode())] local cm = _G["c"..(m or c:GetOriginalCode())]
...@@ -1589,7 +1589,7 @@ end ...@@ -1589,7 +1589,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.TriggerCountUp(c, m, num, con, reset, hc) function VgD.TriggerCountUp(c, m, num, con, reset, hc)
-- check func -- check func
if VgF.IllegalFunctionCheck("TriggerCountUp").con(con) then return end if VgF.IllegalFunctionCheck("TriggerCountUp", c).con(con) then return end
-- set param -- set param
local cm = _G["c"..(m or c:GetOriginalCode())] local cm = _G["c"..(m or c:GetOriginalCode())]
cm.is_has_continuous = cm.is_has_continuous or not reset cm.is_has_continuous = cm.is_has_continuous or not reset
...@@ -1633,7 +1633,7 @@ end ...@@ -1633,7 +1633,7 @@ end
---@return Effect 这个效果 ---@return Effect 这个效果
function VgD.CannotBeTarget(c, m, loc, typ, val, con, tg, loc_self) function VgD.CannotBeTarget(c, m, loc, typ, val, con, tg, loc_self)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("CannotBeTarget") local fchk = VgF.IllegalFunctionCheck("CannotBeTarget", c)
if fchk.con(con) or fchk.tg(tg) then return end if fchk.con(con) or fchk.tg(tg) then return end
-- set param -- set param
local cm = _G["c"..(m or c:GetOriginalCode())] local cm = _G["c"..(m or c:GetOriginalCode())]
...@@ -1777,7 +1777,7 @@ end ...@@ -1777,7 +1777,7 @@ end
---@param con function|nil 这个效果的条件函数 ---@param con function|nil 这个效果的条件函数
function VgD.GlobalCheckEffect(c, m, code, con, op) function VgD.GlobalCheckEffect(c, m, code, con, op)
-- check func -- check func
local fchk = VgF.IllegalFunctionCheck("GlobalCheckEffect") local fchk = VgF.IllegalFunctionCheck("GlobalCheckEffect", c)
if fchk.con(con) or fchk.op(op) then return end if fchk.con(con) or fchk.op(op) then return end
-- set param and check global -- set param and check global
m = m or c:GetOriginalCode() m = m or c:GetOriginalCode()
......
...@@ -1374,12 +1374,14 @@ function VgF.PlayerEffect(e, tp, eg, ep, ev, re, r, rp) ...@@ -1374,12 +1374,14 @@ function VgF.PlayerEffect(e, tp, eg, ep, ev, re, r, rp)
return true return true
end end
---创建一个函数检查器 检查func是否为nil或函数 ---创建一个函数检查器 检查func是否为nil或函数
function VgF.IllegalFunctionCheck(name) function VgF.IllegalFunctionCheck(name, c)
if VgF.GetValueType(c) ~= "Card" then Debug.Message("VgD."..name.." param c isn't Card") end
local m = c:GetOriginalCode()
local chk = function(key) local chk = function(key)
return function(func) return function(func)
local ftyp = type(func) local ftyp = type(func)
if ftyp == "nil" or ftyp == "function" then return false end if ftyp == "nil" or ftyp == "function" then return false end
Debug.Message("c"..self_code.." VgD."..name.." param "..key.." isn't function | nil") Debug.Message("c"..m.." VgD."..name.." param "..key.." isn't function | nil")
return true return true
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment