Commit 50106859 authored by nekrozar's avatar nekrozar Committed by mercury233

update aux.AddXyzProcedureLevelFree (#923)

parent 03834b9f
......@@ -2,7 +2,7 @@
function c43490025.initial_effect(c)
--xyz summon
c:EnableReviveLimit()
aux.AddXyzProcedureLevelFree(c,c43490025.mfilter,c43490025.xyzcheck,1,2)
aux.AddXyzProcedureLevelFree(c,c43490025.mfilter,c43490025.xyzcheck,2,2,c43490025.ovfilter,aux.Stringid(43490025,1))
--atkup
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
......@@ -31,18 +31,13 @@ function c43490025.initial_effect(c)
end
c43490025.xyz_number=0
function c43490025.mfilter(c,xyzc)
return (not c:IsSetCard(0x48) and c:IsXyzType(TYPE_XYZ)) or (c:IsSetCard(0x107f) or c:IsCode(65305468))
end
function c43490025.gfilter(c)
return c:IsSetCard(0x48) or not c:IsXyzType(TYPE_XYZ)
return c:IsXyzType(TYPE_XYZ) and not c:IsSetCard(0x48)
end
function c43490025.xyzcheck(g,xyzc)
if g:GetCount()==1 then
local tc=g:GetFirst()
return tc:IsSetCard(0x107f) or tc:IsCode(65305468)
else
return g:GetClassCount(Card.GetRank)==1 and not g:IsExists(c43490025.gfilter,1,nil)
end
return g:GetClassCount(Card.GetRank)==1
end
function c43490025.ovfilter(c)
return c:IsFaceup() and (c:IsSetCard(0x107f) or c:IsCode(65305468))
end
function c43490025.atkfilter(c)
return c:IsType(TYPE_XYZ) and c:IsSetCard(0x48)
......
......@@ -2,15 +2,7 @@
function c52653092.initial_effect(c)
--xyz summon
c:EnableReviveLimit()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetRange(LOCATION_EXTRA)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetCondition(c52653092.xyzcon)
e1:SetOperation(c52653092.xyzop)
e1:SetValue(SUMMON_TYPE_XYZ)
c:RegisterEffect(e1)
aux.AddXyzProcedureLevelFree(c,c52653092.mfilter,c52653092.xyzcheck,3,3,c52653092.ovfilter,aux.Stringid(52653092,0),c52653092.xyzop)
--cannot disable spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
......@@ -50,99 +42,21 @@ function c52653092.initial_effect(c)
c:RegisterEffect(e6)
end
c52653092.xyz_number=0
function c52653092.mfilter(c,xyzc)
return c:IsFaceup() and c:IsXyzType(TYPE_XYZ) and c:IsSetCard(0x48)
end
function c52653092.xyzcheck(g,xyzc)
return g:GetClassCount(Card.GetRank)==1
end
function c52653092.cfilter(c)
return c:IsSetCard(0x95) and c:GetType()==TYPE_SPELL and c:IsDiscardable()
end
function c52653092.ovfilter(c)
return c:IsFaceup() and c:IsSetCard(0x107f)
end
function c52653092.mfilter(c,xyzc)
return c:IsFaceup() and c:IsXyzType(TYPE_XYZ) and c:IsSetCard(0x48) and c:IsCanBeXyzMaterial(xyzc)
end
function c52653092.xyzfilter1(c,g)
return g:IsExists(c52653092.xyzfilter2,2,c,c:GetRank())
end
function c52653092.xyzfilter2(c,rk)
return c:GetRank()==rk
end
function c52653092.xyzcon(e,c,og,min,max)
if c==nil then return true end
local tp=c:GetControler()
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ct=-ft
if 3<=ct then return false end
if min and (min>3 or max<3) then return false end
local altmg=nil
if og then
altmg=og
else
altmg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
if ct<1 and (not min or min<=1) and altmg:IsExists(aux.XyzAlterFilter,1,nil,c52653092.ovfilter,c)
and Duel.IsExistingMatchingCard(c52653092.cfilter,tp,LOCATION_HAND,0,1,nil) then
return true
end
local mg=nil
if og then
mg=og:Filter(c52653092.mfilter,nil,c)
else
mg=Duel.GetMatchingGroup(c52653092.mfilter,tp,LOCATION_MZONE,0,nil,c)
end
return mg:IsExists(c52653092.xyzfilter1,1,nil,mg)
end
function c52653092.xyzop(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
sg:Merge(tc:GetOverlayGroup())
tc=og:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(og)
Duel.Overlay(c,og)
return
end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ct=-ft
local mg=nil
local altmg=nil
if og then
mg=og:Filter(c52653092.mfilter,nil,c)
altmg=og
else
mg=Duel.GetMatchingGroup(c52653092.mfilter,tp,LOCATION_MZONE,0,nil,c)
altmg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local b1=mg:IsExists(c52653092.xyzfilter1,1,nil,mg)
local b2=ct<1 and (not min or min<=1) and altmg:IsExists(aux.XyzAlterFilter,1,nil,c52653092.ovfilter,c)
and Duel.IsExistingMatchingCard(c52653092.cfilter,tp,LOCATION_HAND,0,1,nil)
if b2 and (not b1 or Duel.SelectYesNo(tp,aux.Stringid(52653092,0))) then
Duel.DiscardHand(tp,c52653092.cfilter,1,1,REASON_COST+REASON_DISCARD,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local g=altmg:FilterSelect(tp,aux.XyzAlterFilter,1,1,nil,c52653092.ovfilter,c)
local g2=g:GetFirst():GetOverlayGroup()
if g2:GetCount()~=0 then
Duel.Overlay(c,g2)
end
c:SetMaterial(g)
Duel.Overlay(c,g)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local g1=mg:FilterSelect(tp,c52653092.xyzfilter1,1,1,nil,mg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local g2=mg:FilterSelect(tp,c52653092.xyzfilter2,2,2,g1:GetFirst(),g1:GetFirst():GetRank())
g1:Merge(g2)
local sg=Group.CreateGroup()
local tc=g1:GetFirst()
while tc do
sg:Merge(tc:GetOverlayGroup())
tc=g1:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(g1)
Duel.Overlay(c,g1)
end
function c52653092.xyzop(e,tp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c52653092.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.DiscardHand(tp,c52653092.cfilter,1,1,REASON_COST+REASON_DISCARD,nil)
end
function c52653092.effcon(e)
return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
......
......@@ -366,7 +366,7 @@ function Auxiliary.XyzTarget2(f,lv,minc,maxc,alterf,desc,op)
if og and not min then
return true
end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ft=Duel.GetLocationCountFromEx(tp)
local ct=-ft
local minc=minc
local maxc=maxc
......@@ -435,103 +435,251 @@ function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op)
end
end
end
function Auxiliary.AddXyzProcedureLevelFree(c,func,gf,minc,maxc)
function Auxiliary.AddXyzProcedureLevelFree(c,f,gf,minc,maxc,alterf,desc,op)
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(Auxiliary.XyzProcedureLevelFreeCondition(func,gf,minc,maxc))
e1:SetOperation(Auxiliary.XyzProcedureLevelFreeOperation(func,gf,minc,maxc))
if alterf then
e1:SetCondition(Auxiliary.XyzLevelFreeCondition2(f,gf,minc,maxc,alterf,desc,op))
e1:SetTarget(Auxiliary.XyzLevelFreeTarget2(f,gf,minc,maxc,alterf,desc,op))
e1:SetOperation(Auxiliary.XyzLevelFreeOperation2(f,gf,minc,maxc,alterf,desc,op))
else
e1:SetCondition(Auxiliary.XyzLevelFreeCondition(f,gf,minc,maxc))
e1:SetTarget(Auxiliary.XyzLevelFreeTarget(f,gf,minc,maxc))
e1:SetOperation(Auxiliary.XyzLevelFreeOperation(f,gf,minc,maxc))
end
e1:SetValue(SUMMON_TYPE_XYZ)
c:RegisterEffect(e1)
end
function Auxiliary.XyzProcedureLevelFreeFilter(c,xyzcard,func)
return c:IsFaceup() and c:IsCanBeXyzMaterial(xyzcard) and (not func or func(c,xyzcard))
--Xyz Summon(level free)
function Auxiliary.XyzLevelFreeFilter(c,xyzc,f)
return c:IsFaceup() and c:IsCanBeXyzMaterial(xyzc) and (not f or f(c,xyzc))
end
function Auxiliary.XyzProcedureLevelFreeCheck(c,tp,xyzcard,mg,sg,gf,minc,maxc)
function Auxiliary.XyzLevelFreeCheck(c,tp,xyzc,mg,sg,gf,minc,maxc)
sg:AddCard(c)
local ct=sg:GetCount()
local res=(ct>=minc and Auxiliary.XyzProcedureLevelFreeGoal(sg,tp,xyzcard,gf))
or (ct<maxc and mg:IsExists(Auxiliary.XyzProcedureLevelFreeCheck,1,sg,tp,xyzcard,mg,sg,gf,minc,maxc))
local res=(ct>=minc and Auxiliary.XyzLevelFreeGoal(sg,tp,xyzc,gf))
or (ct<maxc and mg:IsExists(Auxiliary.XyzLevelFreeCheck,1,sg,tp,xyzc,mg,sg,gf,minc,maxc))
sg:RemoveCard(c)
return res
end
function Auxiliary.XyzProcedureLevelFreeGoal(g,tp,xyzcard,gf)
return (not gf or gf(g,xyzc)) and Duel.GetLocationCountFromEx(tp,tp,g,xyzcard)>0
end
function Auxiliary.XyzProcedureLevelFreeCondition(func,gf,minct,maxct)
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
local maxc=maxct
if min then
minc=math.max(minc,min)
maxc=math.min(maxc,max)
end
local mg=nil
if og then
mg=og:Filter(Auxiliary.XyzProcedureLevelFreeFilter,nil,c,func)
else
mg=Duel.GetMatchingGroup(Auxiliary.XyzProcedureLevelFreeFilter,tp,LOCATION_MZONE,0,nil,c,func)
end
local sg=Group.CreateGroup()
return maxc>=minc and mg:IsExists(Auxiliary.XyzProcedureLevelFreeCheck,1,sg,tp,c,mg,sg,gf,minc,maxc)
end
function Auxiliary.XyzLevelFreeGoal(g,tp,xyzc,gf)
return (not gf or gf(g,xyzc)) and Duel.GetLocationCountFromEx(tp,tp,g,xyzc)>0
end
function Auxiliary.XyzProcedureLevelFreeOperation(func,gf,minct,maxct)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
local g=nil
if og and not min then
g=og
else
g=Group.CreateGroup()
local mg=nil
if og then
mg=og:Filter(Auxiliary.XyzProcedureLevelFreeFilter,nil,c,func)
else
mg=Duel.GetMatchingGroup(Auxiliary.XyzProcedureLevelFreeFilter,tp,LOCATION_MZONE,0,nil,c,func)
function Auxiliary.XyzLevelFreeCondition(f,gf,minct,maxct)
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
local maxc=maxct
if min then
minc=math.max(minc,min)
maxc=math.min(maxc,max)
end
local mg=nil
if og then
mg=og:Filter(Auxiliary.XyzLevelFreeFilter,nil,c,f)
else
mg=Duel.GetMatchingGroup(Auxiliary.XyzLevelFreeFilter,tp,LOCATION_MZONE,0,nil,c,f)
end
local sg=Group.CreateGroup()
return maxc>=minc and mg:IsExists(Auxiliary.XyzLevelFreeCheck,1,sg,tp,c,mg,sg,gf,minc,maxc)
end
local minc=minct
local maxc=maxct
if min then
minc=math.max(minc,min)
maxc=math.min(maxc,max)
end
function Auxiliary.XyzLevelFreeTarget(f,gf,minct,maxct)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,min,max)
if og and not min then
return true
end
local minc=minct
local maxc=maxct
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
end
local mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local g=Group.CreateGroup()
local ag=mg:Filter(Auxiliary.XyzLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
local ct=g:GetCount()
while ct<maxc and ag:GetCount()>0 do
local minsct=1
local finish=(ct>=minc and Auxiliary.XyzLevelFreeGoal(g,tp,c,gf))
if finish then
minsct=0
if not Duel.SelectYesNo(tp,210) then break end
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local tg=ag:Select(tp,minsct,1,nil)
if tg:GetCount()==0 then break end
g:Merge(tg)
ct=g:GetCount()
ag=mg:Filter(Auxiliary.XyzLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
end
if g:GetCount()>0 then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
local ag=mg:Filter(Auxiliary.XyzProcedureLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
local ct=g:GetCount()
while ct<maxc and ag:GetCount()>0 do
local minsct=1
local finish=(ct>=minc and Auxiliary.XyzProcedureLevelFreeGoal(g,tp,c,gf))
if finish then
minsct=0
if not Duel.SelectYesNo(tp,210) then break end
end
function Auxiliary.XyzLevelFreeOperation(f,gf,minct,maxct)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=og:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local mg=e:GetLabelObject()
if e:GetLabel()==1 then
local mg2=mg:GetFirst():GetOverlayGroup()
if mg2:GetCount()~=0 then
Duel.Overlay(c,mg2)
end
else
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=mg:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
end
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local tg=ag:Select(tp,minsct,1,nil)
if tg:GetCount()==0 then break end
g:Merge(tg)
ct=g:GetCount()
ag=mg:Filter(Auxiliary.XyzProcedureLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
end
end
if g:GetCount()>1 then
local sg=Group.CreateGroup()
for tc in aux.Next(g) do
sg:Merge(tc:GetOverlayGroup())
end
--Xyz summon(level free&alterf)
function Auxiliary.XyzLevelFreeCondition2(f,gf,minct,maxct,alterf,desc,op)
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 mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
if (not min or min<=1) and mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,op) then
return true
end
local minc=minct
local maxc=maxct
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
mg=mg:Filter(Auxiliary.XyzLevelFreeFilter,nil,c,f)
local sg=Group.CreateGroup()
return maxc>=minc and mg:IsExists(Auxiliary.XyzLevelFreeCheck,1,sg,tp,c,mg,sg,gf,minc,maxc)
end
Duel.SendtoGrave(sg,REASON_RULE)
else
local sg=g:GetFirst():GetOverlayGroup()
if sg:GetCount()~=0 then
Duel.Overlay(c,sg)
end
function Auxiliary.XyzLevelFreeTarget2(f,gf,minct,maxct,alterf,desc,op)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,min,max)
if og and not min then
return true
end
local minc=minct
local maxc=maxct
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
end
local mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local g=Group.CreateGroup()
local ag=mg:Filter(Auxiliary.XyzLevelFreeFilter,nil,c,f):Filter(Auxiliary.XyzLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
local b1=ag:GetCount()>0
local b2=(not min or min<=1) and mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,op)
if b2 and (not b1 or Duel.SelectYesNo(tp,desc)) then
e:SetLabel(1)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local sg=mg:FilterSelect(tp,Auxiliary.XyzAlterFilter,1,1,nil,alterf,c,e,tp,op)
if op then op(e,tp,1,sg:GetFirst()) end
g:Merge(sg)
else
e:SetLabel(0)
local ct=g:GetCount()
while ct<maxc and ag:GetCount()>0 do
local minsct=1
local finish=(ct>=minc and Auxiliary.XyzLevelFreeGoal(g,tp,c,gf))
if finish then
minsct=0
if not Duel.SelectYesNo(tp,210) then break end
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local tg=ag:Select(tp,minsct,1,nil)
if tg:GetCount()==0 then break end
g:Merge(tg)
ct=g:GetCount()
ag=ag:Filter(Auxiliary.XyzLevelFreeCheck,g,tp,c,mg,g,gf,minc,maxc)
end
end
if g:GetCount()>0 then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end
end
function Auxiliary.XyzLevelFreeOperation2(f,gf,minct,maxct,alterf,desc,op)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=og:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local mg=e:GetLabelObject()
if e:GetLabel()==1 then
local mg2=mg:GetFirst():GetOverlayGroup()
if mg2:GetCount()~=0 then
Duel.Overlay(c,mg2)
end
else
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=mg:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
end
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
end
end
c:SetMaterial(g)
Duel.Overlay(c,g)
end
end
function Auxiliary.FConditionFilterF2(c,g2)
return g2:IsExists(aux.TRUE,1,c)
......
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