Commit 737d22bd authored by 花桃白音's avatar 花桃白音

fix bug#187s,200s,042,819

parent ba7371d5
Pipeline #32686 passed with stages
in 35 minutes and 5 seconds
......@@ -24,7 +24,7 @@ function cm.initial_effect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_ADD_CODE)
e4:SetRange(LOCATION_HAND+LOCATION_DECK+LOCATION_MZONE+LOCATION_GRAVE+LOCATION_REMOVED)
e4:SetValue(18700011)
e4:SetValue(18700548)
c:RegisterEffect(e4)
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
......
--奇物-133 <万籁携生>植物园
local cm,m,o=GetID()
function cm.initial_effect(c)
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),2)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetDescription(1166)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EFFECT_EXTRA_LINK_MATERIAL)
e0:SetRange(LOCATION_EXTRA)
e0:SetTargetRange(LOCATION_SZONE,0)
e0:SetValue(cm.matval)
e0:SetCondition(cm.LinkCondition(cm.matfilter,2,99,cm.lcheck))
e0:SetTarget(cm.LinkTarget(cm.matfilter,2,99,cm.lcheck))
e0:SetOperation(cm.LinkOperation(cm.matfilter,2,99,cm.lcheck))
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(m,0))
......@@ -39,20 +41,132 @@ function cm.initial_effect(c)
e3:SetOperation(cm.repop)
c:RegisterEffect(e3)
end
function cm.exmatcheck(c,lc,tp)
if not c:IsControler(tp) then return false end
function cm.matfilter(c)
return (c:IsType(TYPE_MONSTER) and c:IsType(TYPE_EFFECT)) or (c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP)))
end
function cm.lcheck(g,lc)
return g:FilterCount(Card.IsLocation,nil,LOCATION_SZONE)<=1
end
function cm.LConditionFilter(c,f,lc)
return (c:IsFaceup() or not c:IsLocation(LOCATION_MZONE)) and (c:IsCanBeLinkMaterial(lc) or c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP))) and (not f or f(c))
end
function cm.LExtraFilter(c,f,lc,tp)
if c:IsLocation(LOCATION_MZONE) and not c:IsFaceup() then return false end
return c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp) and (c:IsCanBeLinkMaterial(lc) or c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP))) and (not f or f(c))
end
function cm.GetLinkCount(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else return 1 end
end
function cm.GetLinkMaterials(tp,f,lc)
local mg=Duel.GetMatchingGroup(cm.LConditionFilter,tp,LOCATION_ONFIELD,0,nil,f,lc)
local mg2=Duel.GetMatchingGroup(cm.LExtraFilter,tp,LOCATION_HAND+LOCATION_SZONE,LOCATION_ONFIELD,nil,f,lc,tp)
if mg2:GetCount()>0 then mg:Merge(mg2) end
return mg
end
function cm.LCheckOtherMaterial(c,mg,lc,tp)
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
for _,te in pairs(le) do
local f=te:GetValue()
local related,valid=f(te,lc,nil,c,tp)
if related and not te:GetHandler():IsCode(m) then return false end
if f and not f(te,lc,mg) then return false end
end
return true
return true
end
function cm.LUncompatibilityFilter(c,sg,lc,tp)
local mg=sg:Filter(aux.TRUE,c)
return not cm.LCheckOtherMaterial(c,mg,lc,tp)
end
function cm.LCheckGoal(sg,tp,lc,gf,lmat)
return sg:CheckWithSumEqual(cm.GetLinkCount,lc:GetLink(),#sg,#sg)
and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg))
and not sg:IsExists(cm.LUncompatibilityFilter,1,nil,sg,lc,tp)
and (not lmat or sg:IsContains(lmat))
end
function cm.LExtraMaterialCount(mg,lc,tp)
for tc in aux.Next(mg) do
local le={tc:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local sg=mg:Filter(aux.TRUE,tc)
local f=te:GetValue()
if not f or f(te,lc,sg) then
te:UseCountLimit(tp)
end
end
end
end
function cm.LinkCondition(f,minc,maxc,gf)
return function(e,c,og,lmat,min,max)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local tp=c:GetControler()
local mg=nil
if og then
mg=og:Filter(cm.LConditionFilter,nil,f,c)
else
mg=cm.GetLinkMaterials(tp,f,c)
end
if lmat~=nil then
if not cm.LConditionFilter(lmat,f,c) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
if fg:IsExists(aux.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(fg)
return mg:CheckSubGroup(cm.LCheckGoal,minc,maxc,tp,c,gf,lmat)
end
end
function cm.LinkTarget(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,lmat,min,max)
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local mg=nil
if og then
mg=og:Filter(cm.LConditionFilter,nil,f,c)
else
mg=cm.GetLinkMaterials(tp,f,c)
end
if lmat~=nil then
if not cm.LConditionFilter(lmat,f,c) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
Duel.SetSelectedCard(fg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local cancel=Duel.GetCurrentChain()==0
local sg=mg:SelectSubGroup(tp,cm.LCheckGoal,cancel,minc,maxc,tp,c,gf,lmat)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
end
end
function cm.matval(e,lc,mg,c,tp)
if e:GetHandler()~=lc then return false,nil end
return c:IsSetCard(0x822),not mg or not mg:IsExists(cm.exmatcheck,1,nil,lc,tp)
function cm.LinkOperation(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,lmat,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
cm.LExtraMaterialCount(g,c,tp)
local cg=g:Filter(Card.IsFacedown,1,nil)
if #cg>0 then Duel.ConfirmCards(tp,cg) end
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
g:DeleteGroup()
end
end
function cm.atkcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=c:GetMaterial()
......
--奇物-144 〈生机葳蕤〉培养罐
local cm,m,o=GetID()
function cm.initial_effect(c)
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),2)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetDescription(1166)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EFFECT_EXTRA_LINK_MATERIAL)
e0:SetRange(LOCATION_EXTRA)
e0:SetTargetRange(LOCATION_SZONE,0)
e0:SetValue(cm.matval)
e0:SetCondition(cm.LinkCondition(cm.matfilter,2,99,cm.lcheck))
e0:SetTarget(cm.LinkTarget(cm.matfilter,2,99,cm.lcheck))
e0:SetOperation(cm.LinkOperation(cm.matfilter,2,99,cm.lcheck))
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(m,0))
......@@ -48,19 +50,130 @@ function cm.initial_effect(c)
e4:SetOperation(cm.spop)
c:RegisterEffect(e4)
end
function cm.exmatcheck(c,lc,tp)
if not c:IsControler(tp) then return false end
function cm.matfilter(c)
return (c:IsType(TYPE_MONSTER) and c:IsType(TYPE_EFFECT)) or (c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP)))
end
function cm.lcheck(g,lc)
return g:FilterCount(Card.IsLocation,nil,LOCATION_SZONE)<=1
end
function cm.LConditionFilter(c,f,lc)
return (c:IsFaceup() or not c:IsLocation(LOCATION_MZONE)) and (c:IsCanBeLinkMaterial(lc) or c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP))) and (not f or f(c))
end
function cm.LExtraFilter(c,f,lc,tp)
if c:IsLocation(LOCATION_MZONE) and not c:IsFaceup() then return false end
return c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp) and (c:IsCanBeLinkMaterial(lc) or c:IsSetCard(0x822) and (c:IsType(TYPE_SPELL) or c:IsType(TYPE_TRAP))) and (not f or f(c))
end
function cm.GetLinkCount(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else return 1 end
end
function cm.GetLinkMaterials(tp,f,lc)
local mg=Duel.GetMatchingGroup(cm.LConditionFilter,tp,LOCATION_ONFIELD,0,nil,f,lc)
local mg2=Duel.GetMatchingGroup(cm.LExtraFilter,tp,LOCATION_HAND+LOCATION_SZONE,LOCATION_ONFIELD,nil,f,lc,tp)
if mg2:GetCount()>0 then mg:Merge(mg2) end
return mg
end
function cm.LCheckOtherMaterial(c,mg,lc,tp)
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
for _,te in pairs(le) do
local f=te:GetValue()
local related,valid=f(te,lc,nil,c,tp)
if related and not te:GetHandler():IsCode(m) then return false end
if f and not f(te,lc,mg) then return false end
end
return true
return true
end
function cm.LUncompatibilityFilter(c,sg,lc,tp)
local mg=sg:Filter(aux.TRUE,c)
return not cm.LCheckOtherMaterial(c,mg,lc,tp)
end
function cm.LCheckGoal(sg,tp,lc,gf,lmat)
return sg:CheckWithSumEqual(cm.GetLinkCount,lc:GetLink(),#sg,#sg)
and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg))
and not sg:IsExists(cm.LUncompatibilityFilter,1,nil,sg,lc,tp)
and (not lmat or sg:IsContains(lmat))
end
function cm.LExtraMaterialCount(mg,lc,tp)
for tc in aux.Next(mg) do
local le={tc:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local sg=mg:Filter(aux.TRUE,tc)
local f=te:GetValue()
if not f or f(te,lc,sg) then
te:UseCountLimit(tp)
end
end
end
end
function cm.LinkCondition(f,minc,maxc,gf)
return function(e,c,og,lmat,min,max)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local tp=c:GetControler()
local mg=nil
if og then
mg=og:Filter(cm.LConditionFilter,nil,f,c)
else
mg=cm.GetLinkMaterials(tp,f,c)
end
if lmat~=nil then
if not cm.LConditionFilter(lmat,f,c) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
if fg:IsExists(aux.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(fg)
return mg:CheckSubGroup(cm.LCheckGoal,minc,maxc,tp,c,gf,lmat)
end
end
function cm.LinkTarget(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,lmat,min,max)
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local mg=nil
if og then
mg=og:Filter(cm.LConditionFilter,nil,f,c)
else
mg=cm.GetLinkMaterials(tp,f,c)
end
if lmat~=nil then
if not cm.LConditionFilter(lmat,f,c) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
Duel.SetSelectedCard(fg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local cancel=Duel.GetCurrentChain()==0
local sg=mg:SelectSubGroup(tp,cm.LCheckGoal,cancel,minc,maxc,tp,c,gf,lmat)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
end
end
function cm.matval(e,lc,mg,c,tp)
if e:GetHandler()~=lc then return false,nil end
return c:IsSetCard(0x822),not mg or not mg:IsExists(cm.exmatcheck,1,nil,lc,tp)
function cm.LinkOperation(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,lmat,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
cm.LExtraMaterialCount(g,c,tp)
local cg=g:Filter(Card.IsFacedown,1,nil)
if #cg>0 then Duel.ConfirmCards(tp,cg) end
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
g:DeleteGroup()
end
end
function cm.rctg(e,tp,eg,ep,ev,re,r,rp,chk)
......
dofile("expansions/script/c20099997.lua")
if fuef then return end
fuef = { DebugMode = false } --2024/10/14
fuef.__index = fuef
fuef.__index = fuef
---------------------------------------------------------------- Standard Register
-- no cod
fuef.I = function(_owner, _handler, _ignore) return fuef:Creat("I", nil, _owner, _handler, _ignore) end
......@@ -17,6 +17,48 @@ for i,str in ipairs({"S,F,E,S+C,F+C,E+C,F+TO,F+TF,S+TO,S+TF,X", "A,QO,QF"}) do
end
end
end
---------------------------------------------------------------- procedure Register (just Noc
function fuef.Proc_XYZ(cf, gf, min, max, ex_loc)
min, max = min or 1, max or 99
return fuef.F(EFFECT_SPSUMMON_PROC):DES("XYZ"):PRO("OE"):RAN("E"):Func("XYZ,PX_con(%1,%2,%3,%4,%5),PX_tg(%1,%2,%3,%4,%5),XyzLevelFreeOperation()",cf,gf,min,max,ex_loc)
end
function fuef.PX_g_goal(g, tp, xyzc, gf)
return (not gf or gf(g, tp, xyzc)) and Duel.GetLocationCountFromEx(tp, tp, g, xyzc) > 0
end
function fuef.PX_con(cf, gf, minc, maxc, ex_loc)
return function(e, c, og, min, max)
if c == nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp, minc, maxc = c:GetControler(), math.max(minc, min or minc), math.min(maxc, max or maxc)
if maxc < minc then return false end
local mg = fugf.Filter(og or fugf.Get(tp, "M"), "XyzLevelFreeFilter", {c, cf})
if ex_loc then mg = mg + fugf.GetFilter(tp, ex_loc, "XyzLevelFreeFilter", {c, cf}) end
local sg = Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL)
if #mg > #(mg + sg) then return false end
Duel.SetSelectedCard(sg)
Auxiliary.GCheckAdditional = Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
local res = mg:CheckSubGroup(fuef.PX_g_goal, minc, maxc, tp, c, gf)
Auxiliary.GCheckAdditional = nil
return res
end
end
function fuef.PX_tg(cf, gf, minc, maxc, ex_loc)
return function(e, tp, eg, ep, ev, re, r, rp, chk, c, og, min, max)
if og and not min then return true end
minc, maxc = math.max(minc, min or minc), math.min(maxc, max or maxc)
local mg = fugf.Filter(og or fugf.Get(tp,"M"), "XyzLevelFreeFilter", {c, cf})
if ex_loc then mg = mg + fugf.GetFilter(tp, ex_loc, "XyzLevelFreeFilter", {c, cf}) end
Duel.SetSelectedCard(Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL))
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
Auxiliary.GCheckAdditional = Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
mg = mg:SelectSubGroup(tp, fuef.PX_g_goal, Duel.IsSummonCancelable(), minc, maxc, tp, c, gf)
Auxiliary.GCheckAdditional = nil
if not mg or #mg == 0 then return false end
mg:KeepAlive()
e:SetLabelObject(mg)
return true
end
end
---------------------------------------------------------------- fuef()
function fuef:__call(_cod, _handler, _ignore)
-- _cod is owner (Creat and Register Noc
......@@ -60,7 +102,8 @@ function fuef:CreatNoc(_owner, _handler, _ignore)
while ori.pre do
ori = ori.pre
end
repeat
repeat
if type(ori.typ) == "table" then ori.typ = ori.typ[1] end
self = fuef:Creat(ori.typ, ori.cod, _owner, _handler, _ignore)
for _,_key in ipairs(fusf.CutString("des,cat,pro,ran,tran,ctl,val,con,cos,tg,op,res,lab,obj", ",", "CreatNoc")) do
if ori[_key] then fuef[_key:upper()](self, table.unpack(ori[_key])) end
......@@ -75,7 +118,7 @@ function fuef:Reg(_handler, _ignore)
local handler = self.handler or self.e:GetOwner()
-- is force Register (use in Card.RegisterEffect
local ignore = _ignore
if _handler then
if _handler then
if _handler == true then -- handler equal owner and ignore == true
ignore = true
elseif _handler == false then -- not Reg (use in FG
......@@ -144,7 +187,7 @@ function fuef:Reload(_from)
self.e:Reset()
self.e = Effect.CreateEffect(_owner)
-- Reset if handler is group
if self.gclo then
if self.gclo then
for _, gcloe in ipairs(self.gclo) do
gcloe:Reset()
end
......@@ -160,7 +203,7 @@ end
function fuef:PreChk(from, ...)
if not self.e then --is Noc
self[from:lower()] = {...}
return false
return false
end
return not self:IsNil("PreChk <- "..from, ...)
end
......@@ -180,7 +223,7 @@ function fuef:Cons_Model(_key, _val)
local _keytype = _key == "typ" and "etyp" or _key
local val, des = fusf.Get_Constant(_keytype, _val)
self[_key] = val
if _key == "cod" and not self.des and fucs.des[des] then self.des = fucs.des[des] end
if _key == "cat" and des then self.des = self.des or des end
return self:Reload("Cons_Model <- ".._key:upper())
end
function fuef:TYP(_val)
......@@ -210,7 +253,7 @@ end
function fuef:CTL(_count, _code, _pro) --count, code, pro
if not self:PreChk("CTL", _count, _code, _pro) then return self end
if type(_count) == "string" or _count > 99 then -- ("n+D") or (m) -> (1, "n+D") or (1, m)
_count, _code, _pro = 1, _count, _code
_count, _code, _pro = 1, _count, _code
end
local res, ctl_val = {_code or 0, _pro or 0}, {
O = EFFECT_COUNT_CODE_OATH,
......@@ -245,7 +288,7 @@ function fuef:Func(_val, _func, ...)
if not (type(_val) == "string" and _val:match("%,")) then -- check _val is val
local val = { _val }
if type(_val) == "string" and _val:match("%%") then val = { _val , ... } end
self.val = val
self.val = val
else -- _val is _func
vals, _func = {_func, ...}, _val
end
......@@ -256,7 +299,7 @@ function fuef:Func(_val, _func, ...)
local fname, fval = func, func
if type(fname) == "table" then
fname = table.remove(fval,1)
else
else
fval = nil
end
-- find fname can match seqs
......@@ -296,12 +339,12 @@ function fuef:Func_Model(_key, _func, ...)
if not self:PreChk(_key:upper(), _func, ...) then return self end
local val_chk = _key == "val" and (tonumber(_func) or fucs.val[_func]) or nil
local vals = select("#", ...) > 0 and { ... } or nil
if type(_func) == "string" and _func:match("%(") then
if type(_func) == "string" and _func:match("%(") then
_func = fusf.Val_Cuts(_func, ...)[1]
vals = _func
if type(_func) == "table" then
_func = table.remove(vals,1)
else
else
vals = nil
end
elseif vals and #vals == 1 and type(vals[1]) == "table" then
......@@ -338,7 +381,7 @@ function fuef:LAB(...)
local _labs = {...}
local labs = { }
for _,_lab in ipairs(_labs) do
if type(_lab) == "string" then
if type(_lab) == "string" then
for _,lab in ipairs(fusf.CutString(_lab, "+", "LAB")) do
labs[#labs + 1] = (lab == "m") and self.e:GetOwner():GetOriginalCode() or tonumber(lab)
end
......@@ -362,11 +405,11 @@ function fuef.initial(_lib, _glo, _exop_func, ...)
cm.es, cm.lib = {}, _lib
cm.initial_effect = cm.initial_effect or function(c)
-- do ex_op
if _exop_func then
if _exop_func then
local place = 1
if type(_exop_func) ~= "table" then _exop_func = { _exop_func } end
for _, exop_func in ipairs(_exop_func) do
if type(exop_func) == "string" then
if type(exop_func) == "string" then
for _, func in ipairs(fusf.CutString(exop_func, ",", "fuef.initial")) do
(fucf[func] or Card[func])(c, exop_val[place])
place = place + 1
......
......@@ -6,7 +6,9 @@ function fugf.Get(_tp, _loc)
return Duel.GetFieldGroup(_tp, fusf.Get_Loc(_loc))
end
function fugf.Filter(_g, _func, _val, _n, ...)
if not _func then return not _n and _g or #_g >= _n end -- nil chk
return fusf.Creat_GF(_func, _val, ...)(_g, _n)
--[[
--if not _func then return not _n and _g or #_g >= _n end -- nil chk
-- trans _val
if type(_val) ~= "table" then _val = { _val } end
local temp_val, v_ind = { }, 0
......@@ -59,6 +61,7 @@ function fugf.Filter(_g, _func, _val, _n, ...)
end
_g = table.remove(temp_g)
return not _n and _g or #_g >= _n
--]]
end
function fugf.GetFilter(_tp, _loc, _func, _val, _n, ...)
return fugf.Filter(fugf.Get(_tp, _loc), _func, _val, _n, ...)
......@@ -96,8 +99,9 @@ function fucf.AddCode(c, ...)
end
fucf.ReviveLimit = Card.EnableReviveLimit
--------------------------------------"Card function" (use in Filter
function fucf.Filter(c, func, ...)
return fugf.Filter(Group.FromCards(c), func, {...},1)
function fucf.Filter(c, _func, ...)
return fusf.Creat_CF(_func, {...})(c)
--return fugf.Filter(Group.FromCards(c), func, {...}, 1)
end
fucf.IsRk = fusf.IsN("GetRank")
fucf.IsLv = fusf.IsN("GetLevel")
......
......@@ -46,7 +46,7 @@ end
function fusf.Get_Constant(_constable, _vals)
-- string chk
if type(_vals) ~= "string" then return _vals end
local _res, _first = 0
local _res = 0
-- cod chk
if _constable == "cod" then
-- EVENT_CUSTOM
......@@ -56,7 +56,7 @@ function fusf.Get_Constant(_constable, _vals)
_res = EVENT_CUSTOM + fusf.M_chk(_vals)
-- EVENT_PHASE or EVENT_PHASE_START
elseif _vals:match("PH") then
for _,_var in ipairs(fusf.CutString(_vals, "+", "Get_Constant_1")) do
for _, _var in ipairs(fusf.CutString(_vals, "+", "Get_Constant_1")) do
local _constable = _var:match("PH") and "cod" or "pha"
_res = _res + fucs[_constable][_var]
end
......@@ -64,11 +64,13 @@ function fusf.Get_Constant(_constable, _vals)
if _res ~= 0 then return _res end
end
-- find _constable
for i,_val in ipairs(fusf.CutString(_vals, "+", "Get_Constant_2")) do
if i == 1 then _first = _val end
_res = _res + (fusf.NotNil(_val) and fucs[_constable][_val:upper()] or 0)
local vals, cons, _des = fusf.CutString(_vals, "+", "Get_Constant_2"), fucs[_constable]
for i = #vals, 1, -1 do
local _val = vals[i]
_des = fucs.des[_val] or _des
_res = _res + cons[_val]
end
return _res, _first
return _res, _des
end
function fusf.Get_Loc(_loc1, _loc2, _from)
-- nil chk
......@@ -93,9 +95,10 @@ function fusf.Get_Loc(_loc1, _loc2, _from)
end
return table.unpack(_locs)
end
function fusf.M_chk(_val)
if _val < 19999999 then return _val + 20000000 end
return _val
function fusf.M_chk(val) -- val : number|string
val = tonumber(val)
if val < 19999999 then return val + 20000000 end
return val
end
function fusf.PostFix_Trans(_str, ...)
local vals, res, temp, i = {...}, { }, { }, 1
......@@ -144,13 +147,14 @@ function fusf.IsN(_func)
return function(_c, _val, _exval)
local c_val = Card[_func](_c, _exval)
if type(_val) == "string" then
local oper, _val = _val:match("([%+%-])(%d+)")
local oper, _val = _val:match("%+%-"), _val:match("%d+")
_val = tonumber(_val)
if oper == "+" then
return c_val >= _val
elseif oper == "-" then
return c_val <= _val
return c_val <= _val
end
return c_val == _val
end
if _val > 0 then return c_val == _val end
return c_val <= -_val -- _val = -n
......@@ -182,19 +186,22 @@ end
function fusf.Get_Func(_c, _func, _val)
if type(_func) ~= "string" then return _func end
local lib = _c.lib or {}
local res = function(_func) return _func end
if _func:match("~") then
_func = _func:sub(2)
res = function(_func) return function(...) return not _func(...) end end
end
-- find cm, lib, fuef, aux
if not _val then
return _c[_func] or lib[_func] or fuef[_func] or aux[_func]
return res(_c[_func] or lib[_func] or fuef[_func] or aux[_func])
end
-- translate vals
for i, val in ipairs(_val) do
if tonumber(val) then
_val[i] = tonumber(val)
end
_val[i] = tonumber(val) or val
end
-- find cm, lib, fuef, aux
for _, Lib in ipairs({_c, lib, fuef, aux}) do
if Lib[_func] then return Lib[_func](table.unpack(_val)) end
if Lib[_func] then return res(Lib[_func](table.unpack(_val))) end
end
Debug.Message("Get_Func not found : ".._func)
return nil
......@@ -242,6 +249,71 @@ function fusf.Val_Cuts_Table_Process(_str, ...) -- "f(%1,,3)" -> {"f", vals[1],
res.len = res_ind
return res
end
function fusf.Creat_CF(_func, _val, ...)
if not _func then return function(c) return true end end
-- trans _val
if type(_val) ~= "table" then _val = { _val } end
local temp_val, v_ind = { }, 0
for _, f_val in ipairs(_val) do
if type(f_val) == "string" then
for _, val in fusf.ForTable(fusf.Val_Cuts(f_val, ...)) do
v_ind = v_ind + 1
temp_val[v_ind] = val
end
else
v_ind = v_ind + 1
temp_val[v_ind] = f_val
end
end
_val, temp_val = temp_val
-- _func is function
if type(_func) == "function" then
return function(c)
return _func(c, table.unpack(_val, 1, v_ind))
end
end
-- _func is string
_func = fusf.PostFix_Trans(_func, ...)
local fucf, Card, aux = fucf, Card, aux
if #_func == 1 then -- _func just one
_func = fucf[_func[1] ] or Card[_func[1] ] or aux[_func[1] ]
return function(c)
return _func(c, table.unpack(_val, 1, v_ind))
end
end
return function(c) -- _func is multi
local stack, v_ind, temp_val = { }, 1
for _, func in ipairs(_func) do
if func == "~" then
stack[#stack] = not stack[#stack]
elseif type(func) == "string" and #func == 1 then
local valR, valL = table.remove(stack), table.remove(stack)
local Cal = {
["+"] = valL and valR,
["-"] = valL and not valR,
["/"] = valL or valR
}
table.insert(stack, Cal[func])
else
if type(func) == "string" then
func = fucf[func] or Card[func] or aux[func]
end
temp_val, v_ind = _val[v_ind], v_ind + 1
if type(temp_val) ~= "table" then temp_val = {temp_val, len = 1} end
table.insert(stack, func(c, table.unpack(temp_val, 1, temp_val.len)))
end
end
return table.remove(stack)
end
end
function fusf.Creat_GF(_func, _val, ...)
local ex_val = {...}
return function(g, n)
g = g:Filter(fusf.Creat_CF(_func, _val, table.unpack(ex_val)), nil)
if not n then return g end
return n > 0 and #g >= n or #g <= -n
end
end
function fusf.ForTable(t, n)
local i, max = 0, t.len or n
return function()
......@@ -272,55 +344,46 @@ function fusf.GetDES(_code, _id, m) -- (0), ("n"), (m), ("+1")
end
return aux.Stringid(_code, _id) -- _code*16 + _id
end
function fusf.GetRES(_flag, _count) -- _flag = a + b/b1/b2 + c | 1
if type(_flag) == "string" then
local temp = 0
if not _count then
_flag = fusf.CutString(_flag, "|", "RES_1")
_flag, _count = _flag[1], tonumber(_flag[2])
end
for _,val in ipairs(fusf.CutString(_flag, "+", "RES_2")) do
if val:match("PH") then
temp = temp + RESET_PHASE
val = fusf.CutString(val, "/", "RES_2")
for i = 2, #val do
temp = temp + fucs.pha[val[i] ]
end
elseif val == "SELF" or val == "OPPO" or val == "CH" or val == "EV" then
temp = temp + fucs.res[val]
else -- add RESET_EVENT
temp = (temp | RESET_EVENT) + fucs.res[val]
end
function fusf.GetRES(_flag, _count) -- _flag = a + b/b1/b2 + c | 1
if type(_flag) ~= "string" then return {_flag or 0, _count} end
if not _count then -- cut count
_flag = fusf.CutString(_flag, "|", "RES")
_flag, _count = _flag[1], tonumber(_flag[2] or 1)
end
local stack = { }
for _, unit in ipairs(fusf.PostFix_Trans(_flag)) do
if unit:match("[+-/]") then
local valR, valL = table.remove(stack), table.remove(stack)
table.insert(stack, unit == "-" and valL - valR or valL | valR)
else
table.insert(stack, fucs.res[unit] or fucs.pha[unit])
end
_flag = temp
end
_flag = table.remove(stack)
if _flag & 0xfff0000 > 0 then _flag = _flag | RESET_EVENT end
if _flag & 0x00003ff > 0 then _flag = _flag | RESET_PHASE end
return {_flag, _count}
end
--------------------------------------"Other Support function"
function fusf.RegFlag(tp_or_c, cod, res, pro, lab, des)
cod = fusf.M_chk(cod)
res = fusf.GetRES(res)
pro = fusf.Get_Constant("pro", pro)
if des then des = fusf.GetDES(des, nil, cod) end
if tonumber(tp_or_c) then
Duel.RegisterFlagEffect(tp_or_c, cod, res[1], pro, res[2] or 1, lab or 0)
function fusf.RegFlag(val, cod, res, pro, lab, des) -- val : Card|Effect|player(number)
cod, res, pro = fusf.M_chk(cod), fusf.GetRES(res), fusf.Get_Constant("pro", pro) or 0
if des then des, pro = fusf.GetDES(des, nil, cod), (pro or 0)|EFFECT_FLAG_CLIENT_HINT end
local typ = aux.GetValueType(val)
if typ == "Card" then
val:RegisterFlagEffect(cod, res[1], pro, res[2] or 1, lab or 0, des)
elseif typ == "Effect" then
val:GetHandler():RegisterFlagEffect(cod, res[1], pro, res[2] or 1, lab or 0, des)
else
tp_or_c:RegisterFlagEffect(cod, res[1], pro, res[2] or 1, lab or 0, des)
Duel.RegisterFlagEffect(val, cod, res[1], pro, res[2] or 1, lab or 0)
end
end
function fusf.GetFlag(val, cod, n1, n2)
local typ, count = aux.GetValueType(val)
if type(cod) == "string" then cod = tonumber(cod) end
if cod < 19999999 then cod = cod + 20000000 end
if typ == "Card" then count = val:GetFlagEffect(cod) end
if typ == "Effect" then count = val:GetHandler():GetFlagEffect(cod) end
if typ == "int" then count = Duel.GetFlagEffect(val, cod) end
if not n1 then return n2 and (count == n2) or count end
if type(n1) == "string" and n1:match("[%+%-]") then
local Cal = {
["+"] = count >= (n2 or math.abs(tonumber(n1))),
["-"] = count <= (n2 or math.abs(tonumber(n1)))
}
return Cal[n1:match("[%+%-]")]
function fusf.GetFlag(val, cod) -- val : Card|Effect|player(number)
cod = fusf.M_chk(cod)
local typ = aux.GetValueType(val)
if typ == "Card" then
return val:GetFlagEffect(cod)
elseif typ == "Effect" then
return val:GetHandler():GetFlagEffect(cod)
end
return Duel.GetFlagEffect(val, cod)
end
\ No newline at end of file
......@@ -219,7 +219,7 @@ fucs.pro = {
CAL = EFFECT_FLAG_DAMAGE_CAL , --可以在伤害计算时发动
OP = EFFECT_FLAG_EVENT_PLAYER , --发动/处理效果的玩家为触发事件的玩家而不是卡片的持有者,如仪式魔人,万魔殿
NR = EFFECT_FLAG_NO_TURN_RESET , --发条等“这张卡在场上只能发动一次”的效果
OE = 0x40400 , --EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE(out effect)
OE = 0x40400 , --EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE(out effect)
}
--Location Variable
fucs.ran = {
......@@ -255,8 +255,6 @@ fucs.res = {
SELF = RESET_SELF_TURN ,
OPPO = RESET_OPPO_TURN ,
CH = RESET_CHAIN ,
PH = RESET_PHASE ,
EV = RESET_EVENT ,
-- 以下自动添加 RESET_EVENT
DIS = RESET_DISABLE ,
SET = RESET_TURN_SET ,
......@@ -273,6 +271,9 @@ fucs.res = {
----组合时点
STD = RESETS_STANDARD ,
RED = RESETS_REDIRECT ,
-- 自动添加
PH = RESET_PHASE ,
EV = RESET_EVENT ,
}
--reason Variable
fucs.rea = {
......
......@@ -53,6 +53,7 @@ function c4204001.initial_effect(c)
e5:SetType(EFFECT_TYPE_QUICK_O)
e5:SetCode(EVENT_FREE_CHAIN)
e5:SetRange(LOCATION_MZONE)
e5:SetCountLimit(1,4204001)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
e5:SetCost(function(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
......
......@@ -98,16 +98,16 @@ end
function cm.tdfilter(c)
return c:IsPublic() and c:IsAbleToDeckAsCost()
end
function cm.discost(e,tp,eg,ep,ev,re,r,rp,chk)
function cm.drcost(e,tp,eg,ep,ev,re,r,rp,chk)
local lg=e:GetHandler():GetLinkedGroup()
if chk==0 then return Duel.IsExistingMatchingCard(cm.tdfilter,tp,0xff,0,3,e:GetHandler()) end
local g=Duel.SelectMatchingCard(tp,cm.tdfilter,tp,tp,0xff,0,3,3,nil)
Duel.SendtoDeck(g,nil,REASON_COST)
end
function cm.distg(e,tp,eg,ep,ev,re,r,rp,chk)
function cm.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function cm.disop(e,tp,eg,ep,ev,re,r,rp)
function cm.drop(e,tp,eg,ep,ev,re,r,rp)
Duel.Draw(tp,1,REASON_EFFECT)
end
\ No newline at end of file
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