Commit 0a4dc03b authored by nekrozar's avatar nekrozar Committed by mercury233

update aux.AddLinkProcedure (#952)

parent e73c8365
--アカシック・マジシャン
function c28776350.initial_effect(c)
c:EnableReviveLimit()
--link summon
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetRange(LOCATION_EXTRA)
e0:SetCondition(c28776350.lkcon)
e0:SetOperation(c28776350.lkop)
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
aux.AddLinkProcedure(c,aux.NOT(aux.FilterBoolFunction(Card.IsLinkType,TYPE_TOKEN)),2,2,c28776350.lcheck)
c:EnableReviveLimit()
--splimit
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
......@@ -56,25 +48,8 @@ end
function c28776350.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return c:IsCode(28776350) and bit.band(sumtype,SUMMON_TYPE_LINK)==SUMMON_TYPE_LINK
end
function c28776350.lkfilter1(c,lc,tp)
return c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and not c:IsLinkType(TYPE_TOKEN) and Duel.IsExistingMatchingCard(c28776350.lkfilter2,tp,LOCATION_MZONE,0,1,c,lc,c,tp)
end
function c28776350.lkfilter2(c,lc,mc,tp)
local mg=Group.FromCards(c,mc)
return c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and c:IsRace(mc:GetRace()) and not c:IsLinkType(TYPE_TOKEN) and Duel.GetLocationCountFromEx(tp,tp,mg,lc)>0
end
function c28776350.lkcon(e,c)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp=c:GetControler()
return Duel.IsExistingMatchingCard(c28776350.lkfilter1,tp,LOCATION_MZONE,0,1,nil,c,tp)
end
function c28776350.lkop(e,tp,eg,ep,ev,re,r,rp,c)
local g1=Duel.SelectMatchingCard(tp,c28776350.lkfilter1,tp,LOCATION_MZONE,0,1,1,nil,c,tp)
local g2=Duel.SelectMatchingCard(tp,c28776350.lkfilter2,tp,LOCATION_MZONE,0,1,1,g1:GetFirst(),c,g1:GetFirst(),tp)
g1:Merge(g2)
c:SetMaterial(g1)
Duel.SendtoGrave(g1,REASON_MATERIAL+REASON_LINK)
function c28776350.lcheck(g,lc)
return g:GetClassCount(Card.GetRace)==1
end
function c28776350.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
......
--星杯神楽イヴ
function c77610772.initial_effect(c)
--link summon
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetRange(LOCATION_EXTRA)
e0:SetCondition(c77610772.linkcon)
e0:SetOperation(c77610772.linkop)
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
aux.AddLinkProcedure(c,nil,2,2,c77610772.lcheck)
c:EnableReviveLimit()
--indes
local e1=Effect.CreateEffect(c)
......@@ -48,29 +40,11 @@ function c77610772.initial_effect(c)
e5:SetOperation(c77610772.spop2)
c:RegisterEffect(e5)
end
function c77610772.linkfilter1(c,lc,tp)
return c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and Duel.IsExistingMatchingCard(c77610772.linkfilter2,tp,LOCATION_MZONE,0,1,c,lc,c,tp)
end
function c77610772.linkfilter2(c,lc,mc,tp)
local mg=Group.FromCards(c,mc)
return c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and not c:IsRace(mc:GetRace()) and not c:IsAttribute(mc:GetAttribute()) and Duel.GetLocationCountFromEx(tp,tp,mg,lc)>0
end
function c77610772.linkcon(e,c)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp=c:GetControler()
return Duel.IsExistingMatchingCard(c77610772.linkfilter1,tp,LOCATION_MZONE,0,1,nil,c,tp)
end
function c77610772.linkop(e,tp,eg,ep,ev,re,r,rp,c)
local g1=Duel.SelectMatchingCard(tp,c77610772.linkfilter1,tp,LOCATION_MZONE,0,1,1,nil,c,tp)
local g2=Duel.SelectMatchingCard(tp,c77610772.linkfilter2,tp,LOCATION_MZONE,0,1,1,g1:GetFirst(),c,g1:GetFirst(),tp)
g1:Merge(g2)
c:SetMaterial(g1)
Duel.SendtoGrave(g1,REASON_MATERIAL+REASON_LINK)
function c77610772.lcheck(g,lc)
return g:GetClassCount(Card.GetRace)==g:GetCount() and g:GetClassCount(Card.GetAttribute)==g:GetCount()
end
function c77610772.incon(e)
local c=e:GetHandler()
return c:IsLinkState()
return e:GetHandler():IsLinkState()
end
function c77610772.repfilter(c,tp,hc)
return c:IsFaceup() and c:IsLocation(LOCATION_MZONE)
......
......@@ -1593,15 +1593,15 @@ function Auxiliary.PendOperation()
end
end
--Link Summon
function Auxiliary.AddLinkProcedure(c,f,min,max)
function Auxiliary.AddLinkProcedure(c,f,min,max,gf)
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)
if max==nil then max=99 end
e1:SetCondition(Auxiliary.LinkCondition(f,min,max))
e1:SetOperation(Auxiliary.LinkOperation(f,min,max))
e1:SetCondition(Auxiliary.LinkCondition(f,min,max,gf))
e1:SetOperation(Auxiliary.LinkOperation(f,min,max,gf))
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
end
......@@ -1613,37 +1613,37 @@ function Auxiliary.GetLinkCount(c)
return 1+0x10000*c:GetLink()
else return 1 end
end
function Auxiliary.LCheckRecursive(c,tp,sg,mg,lc,ct,minc,maxc)
function Auxiliary.LCheckRecursive(c,tp,sg,mg,lc,ct,minc,maxc,gf)
sg:AddCard(c)
ct=ct+1
local res=Auxiliary.LCheckGoal(tp,sg,lc,minc,ct)
or (ct<maxc and mg:IsExists(Auxiliary.LCheckRecursive,1,sg,tp,sg,mg,lc,ct,minc,maxc))
local res=Auxiliary.LCheckGoal(tp,sg,lc,minc,ct,gf)
or (ct<maxc and mg:IsExists(Auxiliary.LCheckRecursive,1,sg,tp,sg,mg,lc,ct,minc,maxc,gf))
sg:RemoveCard(c)
ct=ct-1
return res
end
function Auxiliary.LCheckGoal(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(Auxiliary.GetLinkCount,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
function Auxiliary.LCheckGoal(tp,sg,lc,minc,ct,gf)
return ct>=minc and sg:CheckWithSumEqual(Auxiliary.GetLinkCount,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg,lc))
end
function Auxiliary.LinkCondition(f,minc,maxc)
function Auxiliary.LinkCondition(f,minc,maxc,gf)
return function(e,c)
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=Duel.GetMatchingGroup(Auxiliary.LConditionFilter,tp,LOCATION_MZONE,0,nil,f,c)
local sg=Group.CreateGroup()
return mg:IsExists(Auxiliary.LCheckRecursive,1,nil,tp,sg,mg,c,0,minc,maxc)
return mg:IsExists(Auxiliary.LCheckRecursive,1,nil,tp,sg,mg,c,0,minc,maxc,gf)
end
end
function Auxiliary.LinkOperation(f,minc,maxc)
function Auxiliary.LinkOperation(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(Auxiliary.LConditionFilter,tp,LOCATION_MZONE,0,nil,f,c)
local sg=Group.CreateGroup()
for i=0,maxc-1 do
local cg=mg:Filter(Auxiliary.LCheckRecursive,sg,tp,sg,mg,c,i,minc,maxc)
local cg=mg:Filter(Auxiliary.LCheckRecursive,sg,tp,sg,mg,c,i,minc,maxc,gf)
if cg:GetCount()==0 then break end
local minct=1
if Auxiliary.LCheckGoal(tp,sg,c,minc,i) then
if Auxiliary.LCheckGoal(tp,sg,c,minc,i,gf) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment