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

update aux.AddXyzProcedureLevelFree (#923)

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