Commit d2ec4907 authored by whenmo's avatar whenmo

change EffectTypeTrigger

parent 18f6925f
......@@ -1267,29 +1267,39 @@ end
---@param count integer|nil 指示效果在同一回合内最多发动的次数
---@param property integer|nil 指示效果的特殊属性。如确有必要填,请咨询群主。
function VgD.EffectTypeTrigger(c,m,loc,typ,code,op,cost,con,tg,count,property,stringid)
-- check func
local cm=_G["c"..m]
local f=VgF.True
if not cm.is_has_trigger then cm.is_has_trigger=true end
local type2=EFFECT_TYPE_TRIGGER_F
if VgF.GetValueType(cost)=="function" then type2=EFFECT_TYPE_TRIGGER_O end
if not typ then typ=EFFECT_TYPE_SINGLE end
if not loc then loc=LOCATION_MZONE end
if loc==LOCATION_RZONE then loc=LOCATION_MZONE f=VgF.RMonsterCondition end
if loc==LOCATION_VZONE then loc=LOCATION_MZONE f=VgF.VMonsterCondition end
if not stringid then stringid=1 end
if not property then property=0 end
local e1=Effect.CreateEffect(c)
e1:SetDescription(VgF.Stringid(VgID+1,stringid))
e1:SetType(typ+type2)
if VgF.GetValueType(loc)=="number" then e1:SetRange(loc) end
e1:SetCode(code)
e1:SetProperty(property+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
if count and count>0 then e1:SetCountLimit(count) end
e1:SetCondition(function (e,tp,eg,ep,ev,re,r,rp) return (VgF.GetValueType(con)~="function" or con(e,tp,eg,ep,ev,re,r,rp)) and f(e) end)
if VgF.GetValueType(cost)=="function" then e1:SetCost(cost) end
if VgF.GetValueType(tg)=="function" then e1:SetTarget(tg) end
if VgF.GetValueType(op)=="function" then e1:SetOperation(op) end
c:RegisterEffect(e1)
if not VgD.FunctionLegal(cm..".lua : VgD.EffectTypeTrigger param op", op) then return end
if not VgD.FunctionLegal(cm..".lua : VgD.EffectTypeTrigger param cost", cost) then return end
if not VgD.FunctionLegal(cm..".lua : VgD.EffectTypeTrigger param con", con) then return end
if not VgD.FunctionLegal(cm..".lua : VgD.EffectTypeTrigger param tg", tg) then return end
-- set param
cm.is_has_trigger = true
typ = (typ or EFFECT_TYPE_SINGLE) + (cost and EFFECT_TYPE_TRIGGER_O or EFFECT_TYPE_TRIGGER_F)
local con_exf = VgF.True
loc = loc or LOCATION_MZONE
if loc == LOCATION_RZONE then
loc = LOCATION_MZONE
con_exf = VgF.RMonsterCondition
elseif loc == LOCATION_VZONE then
loc = LOCATION_MZONE
con_exf = VgF.VMonsterCondition
end
-- set effect
local e=Effect.CreateEffect(c)
e:SetDescription(VgF.Stringid(VgID+1,stringid or 1))
e:SetType(typ)
e:SetRange(loc)
e:SetCode(code)
e:SetProperty((property or 1)+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
if count then e:SetCountLimit(count) end
e:SetCondition(function(e,tp,eg,ep,ev,re,r,rp)
return (not con or con(e,tp,eg,ep,ev,re,r,rp)) and con_exf(e)
end)
if cost then e:SetCost(cost) end
if tg then e:SetTarget(tg) end
if op then e:SetOperation(op) end
c:RegisterEffect(e)
end
---当c在loc时,可以发动的【起】效果。
---@param c Card 要触发效果的卡
......@@ -1615,3 +1625,9 @@ end
function VgD.CallInPrisonFilter(c,e,tp)
return c:GetFlagEffect(FLAG_IMPRISON)>0 and (vgf.IsCanBeCalled(c,e,tp) or not c:IsType(TYPE_MONSTER))
end
---检查func是否为nil或函数
function VgD.FunctionLegal(from, func)
if not func or type(func)=="function" then return true end
Debug.Message(from.." is not type function")
return false
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