Commit 5eb93685 authored by mercury233's avatar mercury233 Committed by DailyShana

update Card.IsLinkSummonable and Duel.LinkSummon (#1190)

parent 2419fc3e
......@@ -11,7 +11,7 @@ function c12989604.initial_effect(c)
c:RegisterEffect(e1)
end
function c12989604.filter(c)
return c:IsSpecialSummonable(SUMMON_TYPE_LINK)
return c:IsLinkSummonable(nil)
end
function c12989604.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c12989604.filter,tp,LOCATION_EXTRA,0,1,nil) end
......@@ -22,6 +22,6 @@ function c12989604.activate(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,c12989604.filter,tp,LOCATION_EXTRA,0,1,1,nil)
local tc=g:GetFirst()
if tc then
Duel.SpecialSummonRule(tp,tc,SUMMON_TYPE_LINK)
Duel.LinkSummon(tp,tc,nil)
end
end
......@@ -36,50 +36,25 @@ end
function c15447747.matfilter(c)
return c:IsFaceup() and c:IsSetCard(0x120)
end
function c15447747.lkfilter(c)
return c:IsSetCard(0x120) and c:IsType(TYPE_LINK) and c:IsSpecialSummonable(SUMMON_TYPE_LINK)
function c15447747.lkfilter(c,mg)
return c:IsSetCard(0x120) and c:IsLinkSummonable(mg)
end
function c15447747.lktg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local el={}
local mg=Duel.GetMatchingGroup(c15447747.matfilter,tp,LOCATION_MZONE,0,nil)
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,0,mg)
for tc in aux.Next(g) do
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
tc:RegisterEffect(e1)
table.insert(el,e1)
end
local res=Duel.IsExistingMatchingCard(c15447747.lkfilter,tp,LOCATION_EXTRA,0,1,nil)
for _,e in ipairs(el) do
e:Reset()
end
return res
return Duel.IsExistingMatchingCard(c15447747.lkfilter,tp,LOCATION_EXTRA,0,1,nil,mg)
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c15447747.lkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
local el={}
local mg=Duel.GetMatchingGroup(c15447747.matfilter,tp,LOCATION_MZONE,0,nil)
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,0,mg)
for tc in aux.Next(g) do
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
tc:RegisterEffect(e1)
table.insert(el,e1)
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local xg=Duel.SelectMatchingCard(tp,c15447747.lkfilter,tp,LOCATION_EXTRA,0,1,1,nil)
local tc=xg:GetFirst()
local tg=Duel.SelectMatchingCard(tp,c15447747.lkfilter,tp,LOCATION_EXTRA,0,1,1,nil,mg)
local tc=tg:GetFirst()
if tc then
Duel.SpecialSummonRule(tp,tc,SUMMON_TYPE_LINK)
end
for _,e in ipairs(el) do
e:Reset()
Duel.LinkSummon(tp,tc,mg)
end
end
function c15447747.atkcon(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -1827,26 +1827,50 @@ function Auxiliary.LCheckGoal(sg,tp,lc,gf)
and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg))
and not sg:IsExists(Auxiliary.LUncompatibilityFilter,1,nil,sg,lc)
end
function Auxiliary.LinkCondition(f,min,max,gf)
return function(e,c)
function Auxiliary.LinkCondition(f,minc,maxc,gf)
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 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=Auxiliary.GetLinkMaterials(tp,f,c)
local mg=nil
if og then
mg=og:Filter(Auxiliary.LConditionFilter,nil,f,c)
else
mg=Auxiliary.GetLinkMaterials(tp,f,c)
end
local fg=Auxiliary.GetMustMaterialGroup(tp,EFFECT_MUST_BE_LMATERIAL)
if fg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(fg)
return mg:CheckSubGroup(Auxiliary.LCheckGoal,min,max,tp,c,gf)
return mg:CheckSubGroup(Auxiliary.LCheckGoal,minc,maxc,tp,c,gf)
end
end
function Auxiliary.LinkTarget(f,min,max,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c)
local mg=Auxiliary.GetLinkMaterials(tp,f,c)
function Auxiliary.LinkTarget(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,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(Auxiliary.LConditionFilter,nil,f,c)
else
mg=Auxiliary.GetLinkMaterials(tp,f,c)
end
local fg=Auxiliary.GetMustMaterialGroup(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,Auxiliary.LCheckGoal,cancel,min,max,tp,c,gf)
local sg=mg:SelectSubGroup(tp,Auxiliary.LCheckGoal,cancel,minc,maxc,tp,c,gf)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
......@@ -1854,8 +1878,8 @@ function Auxiliary.LinkTarget(f,min,max,gf)
else return false end
end
end
function Auxiliary.LinkOperation(f,min,max,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,smat,mg)
function Auxiliary.LinkOperation(f,minc,maxc,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
......
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