Commit e795eb09 authored by tsubaki's avatar tsubaki

Delete nef1.lua

parent 8abbc93c
Pipeline #38887 passed with stage
in 3 minutes and 11 seconds
--
Nef = Nef or {}
local os = require("os")
-- require "nef/cardList"
function Nef.unpack(t, i)
i = i or 1
if t[i] then
return t[i], Nef.unpack(t, i + 1)
end
end
function Nef.unpackOneMember(t, member, i)
i = i or 1
if t[i] and t[i][member] then
return t[i][member], Nef.unpackOneMember(t, member, i+1)
end
end
function Nef.AddSynchroProcedureWithDesc(c,f1,f2,ct,desc)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetDescription(desc)
e1:SetCondition(Auxiliary.SynCondition(f1,f2,ct,99))
e1:SetTarget(Auxiliary.SynTarget(f1,f2,ct,99))
e1:SetOperation(Auxiliary.SynOperation(f1,f2,ct,99))
e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1)
return e1
end
function Nef.AddRitualProcEqual(c,filter,desc)
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(Auxiliary.RitualUltimateTarget(filter,Card.GetOriginalLevel,"Equal",LOCATION_HAND,nil,nil))
e1:SetOperation(Auxiliary.RitualUltimateOperation(filter,Card.GetOriginalLevel,"Equal",LOCATION_HAND,nil,nil))
e1:SetDescription(desc)
c:RegisterEffect(e1)
return e1
end
function Nef.AddXyzProcedureWithDesc(c,f,lv,ct,desc,maxct,alterf,op)
if c.xyz_filter==nil then
local code=c:GetOriginalCode()
local mt=_G["c" .. code]
if f then
mt.xyz_filter=function(mc) return f(mc) and mc:IsXyzLevel(c,lv) end
else
mt.xyz_filter=function(mc) return mc:IsXyzLevel(c,lv) end
end
mt.xyz_count=ct
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA)
e1:SetDescription(desc)
if not maxct then maxct=ct end
e1:SetCondition(Auxiliary.XyzCondition(f,lv,ct,maxct))
e1:SetTarget(Auxiliary.XyzTarget(f,lv,ct,maxct))
e1:SetOperation(Auxiliary.XyzOperation(f,lv,ct,maxct))
e1:SetValue(SUMMON_TYPE_XYZ)
c:RegisterEffect(e1)
return e1
end
function Auxiliary.EnablePendulumAttribute(c,reg)
local argTable = {1}
return Nef.EnablePendulumAttributeSP(c,99,Auxiliary.TRUE,argTable,reg,nil)
end
function Nef.GetExtraPendulumEffect(c, code, count)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC_G)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(count or 1, code or 10000000)
e1:SetCondition(Nef.PendConditionSP())
e1:SetOperation(Nef.PendOperationSP())
e1:SetValue(SUMMON_TYPE_PENDULUM)
return e1
end
function Nef.EnablePendulumAttributeSP(c,num,filter,argTable,reg,tag)
local code=c:GetOriginalCode()
local mt=_G["c" .. code]
local mlist={}
mlist.pend_filter=filter
mlist.pend_arg=argTable
mlist.pend_num=num
mlist.pend_tag=tag
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(10000001)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_PZONE)
e2:SetValue(Nef.order_table_new(mlist))
c:RegisterEffect(e2)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC_G)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1, 10000000)
e1:SetCondition(Nef.PendConditionSP())
e1:SetOperation(Nef.PendOperationSP())
e1:SetValue(SUMMON_TYPE_PENDULUM)
c:RegisterEffect(e1)
-- 由于utility处加载nef,不需要再无效效果
-- --disable HINTMSG_SPSUMMON
-- local e2=Effect.CreateEffect(c)
-- e2:SetType(EFFECT_TYPE_FIELD)
-- e2:SetRange(LOCATION_PZONE)
-- e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
-- e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
-- e2:SetTargetRange(1,0)
-- e2:SetTarget(Nef.PendSummonLimitTarget)
-- c:RegisterEffect(e2)
--register by default
if reg==nil or reg then
local e3=Effect.CreateEffect(c)
e3:SetDescription(1160)
e3:SetType(EFFECT_TYPE_ACTIVATE)
e3:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e3)
end
mt.pend_effect1 = e1
--mt.pend_effect2 = e2
end
function Nef.PendSummonCheck(c,e,tp,lscale,rscale,filter,argTable,filter2,argTable2,lpc,rpc)
local eset1={lpc:IsHasEffect(10000001)}
local eset2={rpc:IsHasEffect(10000001)}
if c:IsType(TYPE_RITUAL) then
for _,te in ipairs(eset1) do
local mt=Nef.order_table[te:GetValue()]
if mt.pend_tag and mt.pend_tag:find("GodSprite") then
return c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,true,false)
end
end
for _,te in ipairs(eset2) do
local mt=Nef.order_table[te:GetValue()]
if mt.pend_tag and mt.pend_tag:find("GodSprite") then
return c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,true,false)
end
end
end
return c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,false,false)
end
function Nef.PConditionFilterSP(c,e,tp,lscale,rscale,filter,argTable,filter2,argTable2,lpz,rpz)
local lv=0
if c.pendulum_level then
lv=c.pendulum_level
else
lv=c:GetLevel()
end
local normalCondition = (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM)))
and lv>lscale and lv<rscale and not c:IsForbidden()
and Nef.PendSummonCheck(c,e,tp,lscale,rscale,filter,argTable,filter2,argTable2,lpz,rpz)
local spCondition = filter(c,Nef.unpack(argTable)) and filter2(c,Nef.unpack(argTable2))
return spCondition and normalCondition
end
function Nef.PConditionFilterSP2(c,e,tp,lscale,rscale,filter,argTable,filter2,argTable2,lpz,rpz)
local lv=0
if c.pendulum_level then
lv=c.pendulum_level
else
lv=c:GetLevel()
end
local normalCondition = lv>lscale and lv<rscale and not c:IsForbidden()
and Nef.PendSummonCheck(c,e,tp,lscale,rscale,filter,argTable,filter2,argTable2,lpz,rpz)
local spCondition = filter(c,Nef.unpack(argTable)) and filter2(c,Nef.unpack(argTable2))
return spCondition and normalCondition
end
function Nef.PendConditionSP()
return function(e,c,og)
if c==nil then return true end
local tp=c:GetControler()
local lpz=Duel.GetFieldCard(tp, LOCATION_PZONE, 0)
local rpz=Duel.GetFieldCard(tp, LOCATION_PZONE, 1)
if not (lpz and rpz) then return false end
local n1, filter1, argTable1, tag1, pexfunc1 = Nef.GetPendSPInfo(lpz)
local n2, filter2, argTable2, tag2, pexfunc2 = Nef.GetPendSPInfo(rpz)
local lscale=lpz:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<=0 then return false end
if n1 == 0 or n2 == 0 then return end
if pexfunc1 and pexfunc1(lpz):IsExists(Nef.PConditionFilterSP2,1,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz) then
return true
end
if pexfunc2 and pexfunc2(rpz):IsExists(Nef.PConditionFilterSP2,1,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz) then
return true
end
local loc = 0
if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 then loc = loc + LOCATION_HAND end
if Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_PENDULUM) > 0 then loc = loc + LOCATION_EXTRA end
if loc == 0 then return false end
local g = nil
if og then
g = og:Filter(Card.IsLocation, nil, loc)
return g:IsExists(Nef.PConditionFilterSP,1,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
else
return Duel.IsExistingMatchingCard(Nef.PConditionFilterSP,tp,loc,0,1,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
end
end
end
function Nef.PendOperationSP()
return function(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
local lpz = Duel.GetFieldCard(tp, LOCATION_PZONE, 0)
local rpz = Duel.GetFieldCard(tp, LOCATION_PZONE, 1)
local n1, filter1, argTable1, tag1, pexfunc1 = Nef.GetPendSPInfo(lpz)
local n2, filter2, argTable2, tag2, pexfunc2 = Nef.GetPendSPInfo(rpz)
local lscale = lpz:GetLeftScale()
local rscale = rpz:GetRightScale()
if lscale > rscale then lscale, rscale = rscale, lscale end
local ft1 = Duel.GetLocationCount(tp, LOCATION_MZONE)
local ft2 = Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_PENDULUM)
local ft = Duel.GetUsableMZoneCount(tp)
if Duel.IsPlayerAffectedByEffect(tp, 59822133) then
if ft1 > 0 then ft1 = 1 end
if ft2 > 0 then ft2 = 1 end
ft = 1
end
ft = math.min(ft, n1, n2)
local loc = 0
if ft1 > 0 then loc = loc + LOCATION_HAND end
if ft2 > 0 then loc = loc + LOCATION_EXTRA end
local exg = Group.CreateGroup()
if pexfunc1 then exg:Merge(pexfunc1(lpz)) end
if pexfunc2 then exg:Merge(pexfunc2(rpz)) end
local tg = nil
if og then
tg=exg:Filter(Nef.PConditionFilterSP2,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
local g2=og:Filter(Card.IsLocation,nil,loc):Filter(Nef.PConditionFilterSP,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
tg:Merge(g2)
else
tg=exg:Filter(Nef.PConditionFilterSP2,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
local g2=Duel.GetFieldGroup(tp,loc,0):Filter(Nef.PConditionFilterSP,nil,e,tp,lscale,rscale,filter1,argTable1,filter2,argTable2,lpz,rpz)
tg:Merge(g2)
end
ft1 = math.min(ft1, tg:FilterCount(Card.IsLocation, nil, 0x3ff-LOCATION_EXTRA))
ft2 = math.min(ft2, tg:FilterCount(Card.IsLocation, nil, LOCATION_EXTRA))
local ect = c29724053 and Duel.IsPlayerAffectedByEffect(tp, 29724053) and c29724053[tp]
if ect and ect < ft2 then ft2 = ect end
while true do
local ct1 = tg:FilterCount(Card.IsLocation, nil, 0x3ff-LOCATION_EXTRA)
local ct2 = tg:FilterCount(Card.IsLocation, nil, LOCATION_EXTRA)
local ct = ft
if ct1 > ft1 then ct = math.min(ct, ft1) end
if ct2 > ft2 then ct = math.min(ct, ft2) end
if ct <= 0 then break end
if sg:GetCount() > 0 and not Duel.SelectYesNo(tp, 210) then ft = 0 break end
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
local g = tg:Select(tp, 1, ct, nil)
tg:Sub(g)
sg:Merge(g)
if g:GetCount() < ct then ft = 0 break end
ft = ft - g:GetCount()
ft1 = ft1 - g:FilterCount(Card.IsLocation, nil, 0x3ff-LOCATION_EXTRA)
ft2 = ft2 - g:FilterCount(Card.IsLocation, nil, LOCATION_EXTRA)
end
if ft > 0 then
local tg1 = tg:Filter(Card.IsLocation, nil, 0x3ff-LOCATION_EXTRA)
local tg2 = tg:Filter(Card.IsLocation, nil, LOCATION_EXTRA)
if ft1 > 0 and ft2 == 0 and tg1:GetCount() > 0 and (sg:GetCount() == 0 or Duel.SelectYesNo(tp, 210)) then
local ct = math.min(ft1, ft)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
local g = tg1:Select(tp, 1, ct, nil)
sg:Merge(g)
end
if ft1 == 0 and ft2 > 0 and tg2:GetCount() > 0 and (sg:GetCount() == 0 or Duel.SelectYesNo(tp, 210)) then
local ct = math.min(ft2, ft)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
local g = tg2:Select(tp, 1, ct, nil)
sg:Merge(g)
end
end
Duel.HintSelection(Group.FromCards(lpz))
Duel.HintSelection(Group.FromCards(rpz))
end
end
function Nef.SetPendMaxNum(c, num, reset_flag, property, reset_count)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(10000002)
local property=property or 0
e1:SetProperty(bit.bor(property,EFFECT_FLAG_CANNOT_DISABLE))
e1:SetValue(num)
if reset_flag then
e1:SetReset(reset_flag,reset_count)
end
c:RegisterEffect(e1,true)
end
function Nef.SetPendExTarget(c, filter_func)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(10000003)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_PZONE)
e2:SetValue(filter_func)
c:RegisterEffect(e2)
end
function Nef.GetPendMaxNum(c)
local ret=0
local eset={c:IsHasEffect(10000002)}
for _,te in ipairs(eset) do
local v=te:GetValue()
if v and type(v)=="number" then ret=math.max(ret,v) end
end
return ret
end
function Nef.GetPendSPInfo(c)
local eset={c:IsHasEffect(10000001)}
local eset_ex={c:IsHasEffect(10000003)}
local pend_num = 99
local pend_filter = Auxiliary.TRUE
local pend_arg = {1}
local pend_tag = ""
local pend_extra_func = function() return Group.CreateGroup() end
for _,te in ipairs(eset) do
local mt=Nef.order_table[te:GetValue()]
if mt then
if mt.pend_num then
local pnum = type(mt.pend_num) == "number" and mt.pend_num or mt.pend_num(c)
pend_num = math.min(pend_num, pnum)
end
if mt.pend_filter then
local f1=pend_filter
local arg=mt.pend_arg or {1}
local f2_ori=mt.pend_filter
local f2=function(c)
return not f2_ori or f2_ori(c,table.unpack(arg))
end
pend_filter=function(c) return f1(c) and f2(c) end
end
pend_arg=mt.pend_arg or pend_arg
pend_tag=mt.pend_tag and pend_tag..mt.pend_tag or pend_tag
end
end
for _,te in ipairs(eset_ex) do
local f=te:GetValue()
local oldf=pend_extra_func
pend_extra_func=function(...)
local g=oldf(...)
g:Merge(f(...))
return g
end
end
local max_pend_num = Nef.GetPendMaxNum(c)
if max_pend_num>0 then pend_num = math.min(pend_num,max_pend_num) end
return pend_num, pend_filter, pend_arg, pend_tag, pend_extra_func
end
function Nef.GetFieldLeftScale(tp)
local lpz=Duel.GetFieldCard(tp, LOCATION_PZONE, 0)
if lpz then
return lpz:GetLeftScale()
else
return
end
end
function Nef.GetFieldRightScale(tp)
local rpz=Duel.GetFieldCard(tp, LOCATION_PZONE, 1)
if rpz then
return rpz:GetRightScale()
else
return
end
end
function Nef.EnableDualAttributeSP(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DUAL_SUMMONABLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
c:RegisterEffect(e1)
end
function Nef.EnableDualAttribute(c, flag)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DUAL_SUMMONABLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_CHANGE_TYPE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(aux.DualNormalCondition)
e2:SetValue(TYPE_NORMAL+TYPE_DUAL+TYPE_MONSTER+flag)
c:RegisterEffect(e2)
end
function Nef.IsDate(Year, Month, Day)
local year = Year or -1
local month = Month or -1
local day = Day or -1
local date = os.date("*t")
return (date.year==year or year<0) and (date.month==month or month<0) and (date.day==day or day<0)
end
function Nef.GetDate()
local date = os.date("*t")
return date.year, date.month, date.day
end
function Nef.LogFormat(fmt, ...)
Debug.Message(string.format(fmt, ...))
end
function Nef.kangbazi(e,te)
if te:IsActiveType(TYPE_MONSTER) and te:IsActivated() then
local ec=te:GetOwner()
if ec:IsType(TYPE_XYZ) then
return ec:GetOriginalRank()<=10 and ec:GetOriginalRank()>=4
else
return ec:GetOriginalLevel()<=10 and ec:GetOriginalLevel()>=4
end
else
return false
end
end
Nef.order_table=Nef.order_table or {}
Nef.order_count=Nef.order_count or 0
function Nef.order_table_new(v)
Nef.order_count=Nef.order_count+1
Nef.order_table[Nef.order_count]=v
return Nef.order_count
end
function Nef.CheckGroupRecursive(c,sg,g,f,min,max,ext_params)
sg:AddCard(c)
local ct=sg:GetCount()
local res=(ct>=min and ct<=max and f(sg,table.unpack(ext_params)))
or (ct<max and g:IsExists(Nef.CheckGroupRecursive,1,sg,sg,g,f,min,max,ext_params))
sg:RemoveCard(c)
return res
end
function Nef.CheckGroup(g,f,cg,min,max,...)
local min=min or 1
local max=max or g:GetCount()
if min>max then return false end
local ext_params={...}
local sg=Group.CreateGroup()
if cg then sg:Merge(cg) end
local ct=sg:GetCount()
if ct>=min and ct<=max and f(sg,...) then return true end
return g:IsExists(Nef.CheckGroupRecursive,1,sg,sg,g,f,min,max,ext_params)
end
function Nef.SelectGroup(tp,desc,g,f,cg,min,max,...)
local min=min or 1
local max=max or g:GetCount()
local ext_params={...}
local sg=Group.CreateGroup()
local cg=cg or Group.CreateGroup()
sg:Merge(cg)
local ct=sg:GetCount()
local ag=g:Filter(Nef.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
while ct<max and ag:GetCount()>0 do
local finish=(ct>=min and ct<=max and f(sg,...))
local seg=sg:Clone()
local dmin=min-cg:GetCount()
local dmax=math.min(max-cg:GetCount(),g:GetCount())
seg:Sub(cg)
Duel.Hint(HINT_SELECTMSG,tp,desc)
local tc=ag:SelectUnselect(seg,tp,finish,finish,dmin,dmax)
if not tc then break end
if sg:IsContains(tc) then
sg:RemoveCard(tc)
else
sg:AddCard(tc)
end
ct=sg:GetCount()
ag=g:Filter(Nef.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
end
return sg
end
function Nef.SelectGroupWithCancel(tp,desc,g,f,cg,min,max,...)
local min=min or 1
local max=max or g:GetCount()
local ext_params={...}
local sg=Group.CreateGroup()
local cg=cg or Group.CreateGroup()
sg:Merge(cg)
local ct=sg:GetCount()
local ag=g:Filter(Nef.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
while ct<max and ag:GetCount()>0 do
local finish=(ct>=min and ct<=max and f(sg,...))
local cancel=finish or ct==0
local seg=sg:Clone()
local dmin=min-cg:GetCount()
local dmax=math.min(max-cg:GetCount(),g:GetCount())
seg:Sub(cg)
Duel.Hint(HINT_SELECTMSG,tp,desc)
local tc=ag:SelectUnselect(seg,tp,finish,cancel,dmin,dmax)
if not tc then
if not finish then return end
break
end
if sg:IsContains(tc) then
sg:RemoveCard(tc)
else
sg:AddCard(tc)
end
ct=sg:GetCount()
ag=g:Filter(Nef.CheckGroupRecursive,sg,sg,g,f,min,max,ext_params)
end
return sg
end
function Nef.OverlayCard(c,tc,xm,nchk)
if not nchk and (not c:IsLocation(LOCATION_MZONE) or c:IsFacedown() or not c:IsType(TYPE_XYZ) or tc:IsType(TYPE_TOKEN)) then return end
if tc:IsStatus(STATUS_LEAVE_CONFIRMED) then
tc:CancelToGrave()
end
if tc:GetOverlayCount()>0 then
local og=tc:GetOverlayGroup()
if xm then
Duel.Overlay(c,og)
else
Duel.SendtoGrave(og,REASON_RULE)
end
end
Duel.Overlay(c,tc)
end
function Nef.OverlayFilter(c,nchk)
return nchk or not c:IsType(TYPE_TOKEN)
end
function Nef.OverlayGroup(c,g,xm,nchk)
if not nchk and (not c:IsLocation(LOCATION_MZONE) or c:IsFacedown() or g:GetCount()<=0 or not c:IsType(TYPE_XYZ)) then return end
local tg=g:Filter(Nef.OverlayFilter,nil,nchk)
if tg:GetCount()==0 then return end
local og=Group.CreateGroup()
for tc in aux.Next(tg) do
if tc:IsStatus(STATUS_LEAVE_CONFIRMED) then
tc:CancelToGrave()
end
og:Merge(tc:GetOverlayGroup())
end
if og:GetCount()>0 then
if xm then
Duel.Overlay(c,og)
else
Duel.SendtoGrave(og,REASON_RULE)
end
end
Duel.Overlay(c,tg)
end
function Nef.CheckFieldFilter(g,tp,c,f,...)
return Duel.GetLocationCountFromEx(tp,tp,g,c)>0 and (not f or f(g,...))
end
function Nef.AddXyzProcedureCustom(c,func,gf,minc,maxc,xm,...)
local ext_params={...}
if c.xyz_filter==nil then
local code=c:GetOriginalCode()
local mt=_G["c" .. code]
mt.xyz_filter=func or aux.TRUE
mt.xyz_count=minc
end
local maxc=maxc or minc
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(Nef.XyzProcedureCustomCondition(func,gf,minc,maxc,ext_params))
e1:SetTarget(Nef.XyzProcedureCustomTarget(func,gf,minc,maxc,ext_params))
e1:SetOperation(Nef.XyzProcedureCustomOperation(xm))
e1:SetValue(SUMMON_TYPE_XYZ)
c:RegisterEffect(e1)
return e1
end
function Nef.XyzProcedureCustomTuneMagicianFilter(c,te)
local f=te:GetValue()
return f(te,c)
end
function Nef.XyzProcedureCustomTuneMagicianCheck(c,g)
local eset={c:IsHasEffect(EFFECT_TUNE_MAGICIAN_X)}
for _,te in ipairs(eset) do
if g:IsExists(Nef.XyzProcedureCustomTuneMagicianFilter,1,c,te) then return true end
end
return false
end
function Nef.XyzProcedureCustomCheck(g,xyzc,tp,gf)
if g:IsExists(Nef.XyzProcedureCustomTuneMagicianCheck,1,nil,g) then return false end
return not gf or gf(g,xyzc,tp)
end
function Nef.XyzProcedureCustomFilter(c,xyzcard,func,ext_params)
if c:IsLocation(LOCATION_ONFIELD+LOCATION_REMOVED) and c:IsFacedown() then return false end
return c:IsCanBeXyzMaterial(xyzcard) and (not func or func(c,xyzcard,table.unpack(ext_params)))
end
function Nef.XyzProcedureCustomCondition(func,gf,minct,maxct,ext_params)
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=c:GetControler()
local minc=minct or 2
local maxc=maxct or minct or 63
if min then
minc=math.max(minc,min)
maxc=math.min(maxc,max)
end
local mg=nil
if og then
mg=og:Filter(Nef.XyzProcedureCustomFilter,nil,c,func,ext_params)
else
mg=Duel.GetMatchingGroup(Nef.XyzProcedureCustomFilter,tp,LOCATION_MZONE,0,nil,c,func,ext_params)
end
local sg=Group.CreateGroup()
local ce={Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_XMATERIAL)}
for _,te in ipairs(ce) do
local tc=te:GetHandler()
if not mg:IsContains(tc) then return false end
sg:AddCard(tc)
end
return maxc>=minc and Nef.CheckGroup(mg,Nef.CheckFieldFilter,sg,minc,maxc,tp,c,Nef.XyzProcedureCustomCheck,c,tp,gf)
end
end
function Nef.XyzProcedureCustomTarget(func,gf,minct,maxct,ext_params)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,min,max)
local g=nil
if og and not min then
g=og
else
local mg=nil
if og then
mg=og:Filter(Nef.XyzProcedureCustomFilter,nil,c,func,ext_params)
else
mg=Duel.GetMatchingGroup(Nef.XyzProcedureCustomFilter,tp,LOCATION_MZONE,0,nil,c,func,ext_params)
end
local minc=minct or 2
local maxc=maxct or minct or 63
if min then
minc=math.max(minc,min)
maxc=math.min(maxc,max)
end
local ce={Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_XMATERIAL)}
for _,te in ipairs(ce) do
local tc=te:GetHandler()
sg:AddCard(tc)
end
g=Nef.SelectGroupWithCancel(tp,HINTMSG_XMATERIAL,mg,Nef.CheckFieldFilter,sg,minc,maxc,tp,c,Nef.XyzProcedureCustomCheck,c,tp,gf)
end
if g then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
end
function Nef.XyzProcedureCustomOperation(xm)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
Nef.OverlayGroup(c,g,xm,true)
g:DeleteGroup()
end
end
function Nef.CommonCounterGroup(c, code)
Nef.ccg = Nef.ccg or {}
Nef.counter = Nef.counter or {[0] = {}, [1] = {},}
if not Nef.ccg[code] then
Nef.ccg[code] = Group.CreateGroup()
Nef.ccg[code]:KeepAlive()
Nef.counter[0][code] = 0
Nef.counter[1][code] = 0
end
if not Nef.ccg[code]:IsContains(c) then
Nef.ccg[code]:AddCard(c)
end
end
function Nef.AddCommonCounter(num, code, tp)
if not tp then
Nef.AddCommonCounter(num, code, 0)
Nef.AddCommonCounter(num, code, 1)
return
end
if Nef.ccg[code] then
Nef.counter[tp][code] = Nef.counter[tp][code] + num
if Nef.counter[tp][code] < 0 then Nef.counter[tp][code] = 0 end
local tag = math.min(Nef.counter[tp][code], 11)
local tc = Nef.ccg[code]:GetFirst()
while tc do
if tc:IsControler(tp) then
tc:ResetFlagEffect(999900+code)
if tc:IsLocation(LOCATION_ONFIELD) and tag > 0 then
tc:RegisterFlagEffect(999900+code, RESET_EVENT+0xfe0000, EFFECT_FLAG_CLIENT_HINT+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE, 0, 0,
aux.Stringid(code, tag))
end
end
tc = Nef.ccg[code]:GetNext()
end
end
end
function Nef.SetCommonCounter(num, code, tp)
if not tp then
Nef.SetCommonCounter(num, code, 0)
Nef.SetCommonCounter(num, code, 1)
return
end
if Nef.ccg[code] then
Nef.counter[tp][code] = num
Nef.AddCommonCounter(0, code, tp)
end
end
function Nef.GetCommonCounter(code, tp)
local result = 0
if Nef.counter[tp] then
result = Nef.counter[tp][code] or 0
end
return result
end
function Nef.RefreshCommonCounter(c, code)
local tag = math.min(Nef.counter[c:GetControler()][code], 11)
c:ResetFlagEffect(999900+code)
if tag > 0 then
c:RegisterFlagEffect(999900+code, RESET_EVENT+0xfe0000, EFFECT_FLAG_CLIENT_HINT+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE, 0, 0,
aux.Stringid(code, tag))
end
end
function Nef.AddSummonMusic(c,desc,stype)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
if stype then
e1:SetCondition(Nef.SummonTypeCondition(stype))
end
e1:SetOperation(function()
Duel.Hint(11,0,desc)
end)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e3)
end
function Nef.AddLinkProcedureWithDesc(c,f,min,max,gf,desc)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetDescription(desc or 1166)
if max==nil then max=c:GetLink() end
e1:SetCondition(Auxiliary.LinkCondition(f,min,max,gf))
e1:SetTarget(Auxiliary.LinkTarget(f,min,max,gf))
e1:SetOperation(Auxiliary.LinkOperation(f,min,max,gf))
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
return e1
end
function Nef.DeepCopy(tbl)
local t = {}
for k, v in pairs(tbl) do
if type(v) == "table" then
t[k] = Nef.DeepCopy(v)
else
t[k] = v
end
end
return t
end
function Nef.GetAllArrow(c)
local res = {}
local list = {
LINK_MARKER_BOTTOM_LEFT,
LINK_MARKER_BOTTOM,
LINK_MARKER_BOTTOM_RIGHT,
LINK_MARKER_LEFT,
LINK_MARKER_RIGHT,
LINK_MARKER_TOP_LEFT,
LINK_MARKER_TOP,
LINK_MARKER_TOP_RIGHT,
}
for i = 1, #list do
if c:IsLinkMarker(list[i]) then
res[#res+1] = list[i]
end
end
return res
end
-- this group include cards in szone
function Nef.GetLinkArrowGroup(c)
local g = Group.CreateGroup()
if c:IsOnField() then
local tp = c:GetControler()
local loc = c:GetLocation()
local seq = c:GetSequence()
if c:IsLinkMarker(LINK_MARKER_TOP) then
local tc = Nef.getDir8CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_TOP_LEFT) then
local tc = Nef.getDir7CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_TOP_RIGHT) then
local tc = Nef.getDir9CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_LEFT) then
local tc = Nef.getDir4CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_RIGHT) then
local tc = Nef.getDir6CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_BOTTOM) then
local tc = Nef.getDir2CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_BOTTOM_LEFT) then
local tc = Nef.getDir1CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
if c:IsLinkMarker(LINK_MARKER_BOTTOM_RIGHT) then
local tc = Nef.getDir3CardByPos(tp, loc, seq)
if tc then g:AddCard(tc) end
end
end
return g
end
function Nef.getDir8CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 1 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 5)
elseif seq == 3 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 6)
elseif seq == 5 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 3)
elseif seq == 6 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 1)
end
else
return Duel.GetFieldCard(tp, LOCATION_MZONE, seq)
end
end
function Nef.getDir7CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 2 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 5)
elseif seq == 4 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 6)
elseif seq == 5 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 4)
elseif seq == 6 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 2)
end
else
if seq > 0 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, seq-1)
end
end
end
function Nef.getDir9CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 0 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 5)
elseif seq == 2 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 6)
elseif seq == 5 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 2)
elseif seq == 6 then
return Duel.GetFieldCard(1-tp, LOCATION_MZONE, 4)
end
else
if seq < 4 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, seq+1)
end
end
end
function Nef.getDir4CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if 1 < seq and seq < 5 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, seq-1)
end
else
if 1 < seq and seq < 5 then
return Duel.GetFieldCard(tp, LOCATION_SZONE, seq-1)
end
end
end
function Nef.getDir6CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if 0 < seq and seq < 4 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, seq+1)
end
else
if 0 < seq and seq < 4 then
return Duel.GetFieldCard(tp, LOCATION_SZONE, seq+1)
end
end
end
function Nef.getDir2CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 5 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 1)
elseif seq == 6 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 3)
else
return Duel.GetFieldCard(tp, LOCATION_SZONE, seq)
end
end
end
function Nef.getDir1CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 5 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 0)
elseif seq == 6 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 2)
elseif seq > 0 then
return Duel.GetFieldCard(tp, LOCATION_SZONE, seq-1)
end
end
end
function Nef.getDir3CardByPos(tp, loc, seq)
if loc == LOCATION_MZONE then
if seq == 5 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 2)
elseif seq == 6 then
return Duel.GetFieldCard(tp, LOCATION_MZONE, 4)
elseif seq < 4 then
return Duel.GetFieldCard(tp, LOCATION_SZONE, seq+1)
end
end
end
function Nef.RegisterBigFiendEffect(c,e)
c:RegisterEffect(e)
local ex=e:Clone()
ex:SetRange(LOCATION_HAND)
local con=e:GetCondition()
ex:SetCondition(function(e,tp,eg,ep,ev,re,r,rp)
return (not con or con(e,tp,eg,ep,ev,re,r,rp)) and Duel.IsPlayerAffectedByEffect(tp,22211) and e:GetHandler():IsSetCard(0x222)
end)
if ex:IsHasType(EFFECT_TYPE_IGNITION) then
ex:SetType((ex:GetType() & ~EFFECT_TYPE_IGNITION) | EFFECT_TYPE_QUICK_O)
ex:SetCode(EVENT_FREE_CHAIN)
ex:SetHintTiming(0,0x1c0)
end
c:RegisterEffect(ex)
end
function Auxiliary.NonTuner(f,...)
local ext_params={...}
return function(target,syncard)
return (not syncard or target:IsNotTuner(syncard)) and (not f or f(target,table.unpack(ext_params)))
end
end
if not Nef.SeedField then
local class = {}
class.seeds = {}
class.hint = true
function class.readZone(zone)
local zone0 = zone & 0xff
local zone1 = zone >> 16
local flag0 = math.log(zone0, 2)
local flag1 = math.log(zone1, 2)
return math.log(zone, 2), flag0, flag1, zone0, zone1
end
-- 换算zone为seq,>=16在对方场上
function class.getSeq(zone)
local a, b = class.readZone(zone)
if b > 4 then
return b
else
return a
end
end
-- 换算zone为seq,>=16在玩家1场上,因为extra区算玩家0的,所以转换一下22和21为5和6
function class.getSeq0(zone)
local seq0 = class.getSeq(zone)
if seq0 > 20 then seq0 = 27 - seq0 end
return seq0
end
-- 换算为玩家0的相对zone, extra区域算玩家0的
function class.fmtZone(tp, zone)
if tp == 0 then
return zone
else
local seq, seqTP, seqNTP, zoneTP, zoneNTP = class.readZone(zone)
if seqTP == 5 or seqTP == 6 then
return zoneTP << 16 | zoneNTP
else
if seq >= 16 then
return 1 << (seq - 16)
else
return 1 << (seq + 16)
end
end
end
end
--[[
tp 种子持有者
zone 目标区域
]]
function class.addSeed(e, tp, zoneTP)
local zone = class.fmtZone(tp, zoneTP)
local seq = class.getSeq0(zone)
local p = 0
local pseq = seq
if pseq >= 16 then
p = 1
pseq = pseq - 16
end
if class.isHasSeed(0, seq) or (not Duel.CheckLocation(p, LOCATION_MZONE, seq)) then return false end
local c = e:GetHandler()
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetTarget(class.tg)
e1:SetOperation(class.op)
e1:SetLabel(seq)
Duel.RegisterEffect(e1, tp)
local e2=e1:Clone()
e2:SetCode(EVENT_SUMMON_SUCCESS)
Duel.RegisterEffect(e2, tp)
class.seeds[seq] = {tp, e1, e2}
class.showSeedZone()
return true
end
--[[
tp 种子持有者
p seq的玩家
seq 相对玩家p目标区域序号
]]
function class.addSeedWithSeq(e, tp, p, seq)
local fix = p == tp and 0 or 16
return class.addSeed(e, tp, 1 << (seq + fix))
end
function class.showSeedZone()
if class.hint == false then return end
local zone00, zone01 = 0, 0
local zone10, zone11 = 0, 0
for i = 0, 4 do
if class.seeds[i] then
local p = class.seeds[i][1]
if p == 0 then
zone00 = zone00 | 1<<i
zone10 = zone10 | 1<<(i+16)
else
zone01 = zone01 | 1<<i
zone11 = zone11 | 1<<(i+16)
end
end
if class.seeds[i+16] then
local p = class.seeds[i+16][1]
if p == 0 then
zone00 = zone00 | 1<<(i+16)
zone10 = zone10 | 1<<i
else
zone01 = zone01 | 1<<(i+16)
zone11 = zone11 | 1<<i
end
end
end
for i = 5, 6 do
if class.seeds[i] then
local p = class.seeds[i][1]
if p == 0 then
zone00 = zone00 | 1<<i | 1<<(i+16)
zone10 = zone10 | 1<<i | 1<<(i+16)
else
zone01 = zone01 | 1<<i | 1<<(i+16)
zone11 = zone11 | 1<<i | 1<<(i+16)
end
end
end
if zone10 > 0 then
Duel.Hint(HINT_CODE, 1, 999399)
Duel.Hint(HINT_ZONE, 1, zone10)
else
Duel.Hint(HINT_CODE, 1, 999398)
end
if zone11 > 0 then
Duel.Hint(HINT_CODE, 1, 999397)
Duel.Hint(HINT_ZONE, 1, zone11)
else
Duel.Hint(HINT_CODE, 1, 999396)
end
if zone01 > 0 then
Duel.Hint(HINT_CODE, 0, 999399)
Duel.Hint(HINT_ZONE, 0, zone01)
else
Duel.Hint(HINT_CODE, 0, 999398)
end
if zone00 > 0 then
Duel.Hint(HINT_CODE, 0, 999397)
Duel.Hint(HINT_ZONE, 0, zone00)
else
Duel.Hint(HINT_CODE, 0, 999396)
end
end
function class.addStep()
class.hint = false
end
function class.addComplete()
class.hint = true
class.showSeedZone()
end
function class.getSeedOwner(tp, seq)
local zone0 = class.fmtZone(tp, 1 << seq)
local seq0 = class.getSeq0(zone0)
return class.seeds[seq0] and class.seeds[seq0][1]
end
-- 相对于tp的seq位置是否有种子
function class.isHasSeed(tp, seq)
return class.getSeedOwner(tp, seq) ~= nil
end
-- 相对于tp的seq位置是否有种子, 或该位置上的怪兽是否有种子指示物
function class.isHasSeedEx(tp, seq)
local zc = Duel.GetFieldCard(tp, LOCATION_MZONE, seq)
return class.isHasSeed(tp, seq) or (zc and zc:GetCounter(0x10a2) > 0)
end
-- 删除相对于tp的seq位置的种子
function class.delSeed(tp, seq)
local zone0 = class.fmtZone(tp, 1 << seq)
local seq0 = class.getSeq0(zone0)
local t = class.seeds[seq0]
t[2]:Reset()
t[3]:Reset()
class.seeds[seq0] = nil
class.showSeedZone()
end
function class.isHasSeedOnField()
for _, v in pairs(class.seeds) do
return true
end
return false
end
function class.cfilter(c, seq)
if c:IsLocation(LOCATION_MZONE) then
local p = c:GetControler()
local cseq = c:GetSequence()
if p == 1 then
p = 0
if cseq < 5 then
cseq = cseq + 16
else
cseq = 11 - cseq
end
end
return cseq == seq and class.isHasSeed(p, cseq) and c:IsFaceup()
end
end
function class.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk == 0 then
local seq = e:GetLabel()
return eg:IsExists(class.cfilter, 1, nil, seq)
end
end
function class.op(e,tp,eg,ep,ev,re,r,rp)
local seq = e:GetLabel()
local g = eg:Filter(class.cfilter, nil, seq)
local tg = g:Filter(Card.IsLocation, nil, LOCATION_MZONE)
if tg:GetCount() > 0 then
local c = tg:GetFirst()
local p = class.getSeedOwner(0, seq)
if (c:GetControler() == p) then
Duel.Hint(HINT_CARD, 0, 999312)
-- up atk
local e1=Effect.CreateEffect(e:GetOwner())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(400)
c:RegisterEffect(e1)
-- can not be target
local e2=Effect.CreateEffect(e:GetOwner())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e2:SetValue(aux.tgoval)
e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e2)
else
Duel.Hint(HINT_CARD, 0, 999312)
-- down atk
local e1=Effect.CreateEffect(e:GetOwner())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(-400)
c:RegisterEffect(e1)
-- change race
if not c:IsRace(RACE_PLANT) then
local e1 = Effect.CreateEffect(e:GetOwner())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_RACE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(RACE_PLANT)
e1:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e1)
end
-- change level
if not c:IsType(TYPE_XYZ) and not c:IsType(TYPE_LINK) then
local e2 = Effect.CreateEffect(e:GetOwner())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EFFECT_UPDATE_LEVEL)
e2:SetReset(RESET_EVENT+0x1fe0000)
e2:SetValue(-1)
c:RegisterEffect(e2)
end
end
-- add counter
c:AddCounter(0x10a2, 1)
class.delSeed(0, seq)
end
end
Nef.SeedField = class
end
if not Nef.PLCounter then
local class = {}
class._e = {
[0] = {},
[1] = {},
}
class._n = {
[0] = {},
[1] = {},
}
function class.Add(tp, code, num)
local eg = class._e[tp][code]
if eg then
--local e = eg:GetLabelObject()
--e:Reset()
eg:Reset()
end
local e1 = Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CLIENT_HINT+EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
--local eg1 = Effect.GlobalEffect()
--eg1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_GRANT)
--eg1:SetTargetRange(0xff, 0)
--eg1:SetTarget(aux.TRUE)
local count = (class._n[tp][code] or 0) + num
--椿季赛特供椿天场地
--if code==999104 then count=1 end
class._e[tp][code] = e1
class._n[tp][code] = count
e1:SetDescription(aux.Stringid(code, count))
--eg1:SetLabelObject(e1)
Duel.RegisterEffect(e1, tp)
end
function class.AddWithPhaseReset(tp,code,num,te,phase,resetnum,resetcount,resettp,othercon)
class.Add(tp,code,num)
if te==nil or phase==nil then return end
if resetcount==nil then resetcount=0 end
local e1=Effect.CreateEffect(te:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EVENT_PHASE+phase)
if resettp==nil then
e1:SetLabel(Duel.GetTurnCount())
else
e1:SetLabel(Duel.GetTurnCount(resettp))
end
if othercon==nil then
e1:SetCondition(class.resetcon(resetcount,resettp))
else
e1:SetCondition(othercon)
end
e1:SetOperation(class.resetop(code,num,resetnum))
Duel.RegisterEffect(e1,tp)
end
function class.resetcon(resetcount,resettp)
return function(e,tp,eg,ep,ev,re,r,rp)
if resettp==nil then
return Duel.GetTurnCount()>=e:GetLabel()+resetcount
else
return Duel.GetTurnCount(resettp)>=e:GetLabel()+resetcount and Duel.GetTurnPlayer()==resettp
end
end
end
function class.resetop(code,num,resetnum)
return function(e,tp,eg,ep,ev,re,r,rp)
if resetnum==nil then
local num2=class.Get(tp,code)
if num2-num<0 then num=num2 end
Duel.Hint(HINT_CARD,0,e:GetHandler():GetOriginalCode())
class.Add(tp,code,-num)
e:Reset()
else
local num2=class.Get(tp,code)
Duel.Hint(HINT_CARD,0,e:GetHandler():GetOriginalCode())
class.Add(tp,code,resetnum-num2)
e:Reset()
end
end
end
function class.Get(tp, code)
return class._n[tp][code] or 0
end
Nef.PLCounter = class
end
--seasonchange
function Nef.SeasonChange(c)
if Nef.Seasoncounter == nil then
Nef.Seasoncounter = true
local sea=Effect.CreateEffect(c)
sea:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
sea:SetCode(EVENT_PHASE_START+PHASE_STANDBY)
sea:SetOperation(Nef.addcount)
Duel.RegisterEffect(sea, 0)
end
end
function Nef.addcount(e,tp,eg,ep,ev,re,r,rp)
if Nef.PLCounter.Get(tp,999104) < 4 then
Nef.PLCounter.Add(tp,999104,1)
Nef.PLCounter.Add(1-tp,999104,1)
else
Nef.PLCounter.Add(tp,999104,-3)
Nef.PLCounter.Add(1-tp,999104,-3)
end
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