Commit 4f6c266a authored by wyykak's avatar wyykak

fix exlink by gugu

Signed-off-by: wyykak's avatarwyykak <wyy_1414@126.com>
parent c3cb0608
Pipeline #26211 passed with stage
in 16 seconds
Exlink = Exlink or {}
--extra link
function Exlink.AddLinkProcedure(c,f,min,max,mattg,matval,loc1,loc2,count,code,gf)
local e1=Effect.CreateEffect(c)
e1:SetDescription(1166)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA)
if max==nil then max=c:GetLink() end
e1:SetCondition(Exlink.LinkCondition(f,min,max,loc1,loc2,gf))
e1:SetTarget(Exlink.LinkTarget(f,min,max,loc1,loc2,gf))
e1:SetOperation(Exlink.LinkOperation(f,min,max,loc1,loc2,gf))
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
--extra material
if mattg and matval and (loc1 or loc2) then
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE)
e2:SetCode(EFFECT_EXTRA_LINK_MATERIAL)
e2:SetRange(LOCATION_EXTRA)
if count then
if code==nil then code=c:GetOriginalCode() end
e2:SetCountLimit(count,code)
end
e2:SetLabel(404)
e2:SetTarget(Exlink.exmattg(mattg))
e2:SetTargetRange(loc1,loc2)
e2:SetValue(Exlink.exmatval(matval))
c:RegisterEffect(e2)
end
return e1
end
function Exlink.LConditionFilter(c,f,lc,e)
return (c:IsFaceup() or not c:IsOnField() or e:IsHasProperty(EFFECT_FLAG_SET_AVAILABLE))
and c:IsCanBeLinkMaterial(lc) and (not f or f(c))
end
function Exlink.LExtraFilter(c,f,lc,tp)
if c:IsOnField() and c:IsFacedown() then return false end
if not c:IsCanBeLinkMaterial(lc) or f and not f(c) then return false end
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local tf=te:GetValue()
local related,valid=tf(te,lc,nil,c,tp)
if related and valid then return true end
end
return false
end
function Exlink.LExtraFilter2(c,f,lc,tp)
if not c:IsCanBeLinkMaterial(lc) or f and not f(c) then return false end
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local tf=te:GetValue()
local label=te:GetLabel()
local related,valid=tf(te,lc,nil,c,tp)
if related and valid and label and label==404 then return true end
end
return false
end
function Exlink.GetLinkCount(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else return 1 end
end
function Exlink.GetLinkMaterials(tp,f,lc,e,loc1,loc2)
local mg=Duel.GetMatchingGroup(Exlink.LConditionFilter,tp,LOCATION_MZONE,0,nil,f,lc,e)
local mg2=Duel.GetMatchingGroup(Exlink.LExtraFilter,tp,LOCATION_HAND+LOCATION_SZONE,LOCATION_ONFIELD,nil,f,lc,tp)
local mg3=Duel.GetMatchingGroup(Exlink.LExtraFilter2,tp,loc1,loc2,nil,f,lc,tp)
if mg2:GetCount()>0 then mg:Merge(mg2) end
if mg3:GetCount()>0 then mg:Merge(mg3) end
return mg
end
function Exlink.LCheckOtherMaterial(c,mg,lc,tp)
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
local res1=false
local res2=true
for _,te in pairs(le) do
local f=te:GetValue()
local related,valid=f(te,lc,mg,c,tp)
if related then res2=false end
if related and valid then res1=true end
end
return res1 or res2
end
function Exlink.LUncompatibilityFilter(c,sg,lc,tp)
local mg=sg:Filter(aux.TRUE,c)
return not Exlink.LCheckOtherMaterial(c,mg,lc,tp)
end
function Exlink.LCheckGoal(sg,tp,lc,gf,lmat)
return sg:CheckWithSumEqual(Exlink.GetLinkCount,lc:GetLink(),#sg,#sg)
and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg,lc,tp))
and not sg:IsExists(Exlink.LUncompatibilityFilter,1,nil,sg,lc,tp)
and (not lmat or sg:IsContains(lmat))
end
function Exlink.LExtraMaterialCount(mg,lc,tp)
for tc in aux.Next(mg) do
local le={tc:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local sg=mg:Filter(aux.TRUE,tc)
local f=te:GetValue()
local related,valid=f(te,lc,sg,tc,tp)
if related and valid then
te:UseCountLimit(tp)
end
end
end
end
function Exlink.LinkCondition(f,minc,maxc,loc1,loc2,gf)
return function(e,c,og,lmat,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=nil
if og then
mg=og:Filter(Exlink.LConditionFilter,nil,f,c,e)
else
mg=Exlink.GetLinkMaterials(tp,f,c,e,loc1,loc2)
end
if lmat~=nil then
if not Exlink.LConditionFilter(lmat,f,c,e) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
if fg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(fg)
return mg:CheckSubGroup(Exlink.LCheckGoal,minc,maxc,tp,c,gf,lmat)
end
end
function Exlink.LinkTarget(f,minc,maxc,loc1,loc2,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,lmat,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(Exlink.LConditionFilter,nil,f,c,e)
else
mg=Exlink.GetLinkMaterials(tp,f,c,e,loc1,loc2)
end
if lmat~=nil then
if not Exlink.LConditionFilter(lmat,f,c,e) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
Duel.SetSelectedCard(fg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local cancel=Duel.IsSummonCancelable()
local sg=mg:SelectSubGroup(tp,Exlink.LCheckGoal,cancel,minc,maxc,tp,c,gf,lmat)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
end
end
function Exlink.LinkOperation(f,minc,maxc,loc1,loc2,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,lmat,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
Exlink.LExtraMaterialCount(g,c,tp)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
g:DeleteGroup()
end
end
function Exlink.exmattg(mattg)
return function(e,c)
return mattg(e,c)
end
end
function Exlink.exmatval(matval)
return function(e,lc,mg,c,tp)
return matval(e,lc,mg,c,tp)
end
end
\ No newline at end of file
......@@ -6,6 +6,7 @@ Duel.LoadScript("nef/elf.lua")
Duel.LoadScript("nef/dss.lua")
Duel.LoadScript("nef/afi.lua")
Duel.LoadScript("nef/TheElementTheory.lua")
Duel.LoadScript("nef/Exlink.lua")
-- require "expansions/script/nef/nef"
-- require "expansions/script/nef/msc"
......
--花与妖的连结✿风见幽香
function c25501.initial_effect(c)
c:EnableReviveLimit()
--link summon
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:SetCondition(c25501.lkcon)
e1:SetOperation(c25501.lkop)
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
Exlink.AddLinkProcedure(c,nil,7,nil,c25501.mattg,c25501.matval,0,LOCATION_MZONE)
c:EnableReviveLimit()
--atk
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
......@@ -35,81 +27,15 @@ function c25501.initial_effect(c)
e6:SetValue(c25501.efilter)
c:RegisterEffect(e6)
end
--
function c25501.lkfilter(c,lc,tp)
local flag=c:IsFaceup() and c:IsCanBeLinkMaterial(lc)
if c:IsControler(tp) then
return flag and c:IsType(TYPE_MONSTER)
else
return flag and c:IsType(TYPE_MONSTER) and not c:IsType(TYPE_LINK)
end
end
function c25501.lvfilter(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else
return 1
end
end
--
function c25501.lcheck(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(c25501.lvfilter,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function c25501.lkchenk(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=c25501.lcheck(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c25501.lkchenk,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
--
function c25501.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()
local mg=Duel.GetMatchingGroup(c25501.lkfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
local pc=pe:GetHandler()
if not mg:IsContains(pc) then return false end
sg:AddCard(pc)
end
local ct=sg:GetCount()
local minc=7
local maxc=8
if ct>maxc then return false end
return c25501.lcheck(tp,sg,c,minc,ct) or mg:IsExists(c25501.lkchenk,1,nil,tp,sg,mg,c,ct,minc,maxc)
function c25501.mattg(e,c)
local tp=e:GetHandler():GetControler()
local check1=c:IsType(TYPE_MONSTER) and (c:IsOnField() or c:IsFacedown())
return check1 and not (c:IsType(TYPE_LINK) and c:IsControler(1-tp))
end
--
function c25501.lkop(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(c25501.lkfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
sg:AddCard(pe:GetHandler())
end
local ct=sg:GetCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
sg:Select(tp,ct,ct,nil)
local minc=7
local maxc=8
for i=ct,maxc-1 do
local cg=mg:Filter(c25501.lkchenk,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c25501.lcheck(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local g=cg:Select(tp,minct,1,nil)
if g:GetCount()==0 then break end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
function c25501.matval(e,lc,mg,c,tp)
if e:GetHandler()~=lc then return false,nil end
return true,not mg or mg
end
--
function c25501.atkval(e,c)
return c:GetLinkedGroupCount()*1000
end
......
--蓬莱-永夜的隐者✿八意永琳
function c86379558.initial_effect(c)
--link summon
c:EnableReviveLimit()
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(c86379558.lkcon1)
e0:SetOperation(c86379558.lkop1)
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
Exlink.AddLinkProcedure(c,nil,7,nil,c86379558.mattg,c86379558.matval,LOCATION_ONFIELD,LOCATION_ONFIELD)
--moon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
......@@ -38,6 +29,13 @@ function c86379558.initial_effect(c)
e3:SetOperation(c86379558.lpop)
c:RegisterEffect(e3)
end
function c86379558.mattg(e,c)
return c:IsOnField() and c:IsFacedown()
end
function c86379558.matval(e,lc,mg,c,tp)
if e:GetHandler()~=lc then return false,nil end
return true,not mg or mg
end
--
function c86379558.indes(e,c)
return c:IsFaceup() and c:IsSetCard(0x257) and c:IsType(TYPE_SPELL+TYPE_TRAP)
......@@ -59,73 +57,3 @@ function c86379558.damop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_CARD,0,86379558)
Duel.SetLP(1-tp,Duel.GetLP(1-tp)-1800)
end
--
function c86379558.lkfilter1(c,lc,tp)
if c:IsType(TYPE_MONSTER) and c:IsFaceup() then
return c:IsCanBeLinkMaterial(lc) and c:IsControler(tp)
else
return c:IsFacedown()
end
end
function c86379558.lvfilter1(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else
return 1
end
end
function c86379558.lcheck1(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(c86379558.lvfilter1,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function c86379558.lkchenk1(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=c86379558.lcheck1(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c86379558.lkchenk1,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
function c86379558.lkcon1(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(c86379558.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
local pc=pe:GetHandler()
if not mg:IsContains(pc) then return false end
sg:AddCard(pc)
end
local ct=sg:GetCount()
local minc=7
local maxc=8
if ct>maxc then return false end
return (c86379558.lcheck1(tp,sg,c,minc,ct) or mg:IsExists(c86379558.lkchenk1,1,nil,tp,sg,mg,c,ct,minc,maxc))
end
function c86379558.lkop1(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(c86379558.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
sg:AddCard(pe:GetHandler())
end
local ct=sg:GetCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
sg:Select(tp,ct,ct,nil)
local minc=7
local maxc=8
for i=ct,maxc-1 do
local cg=mg:Filter(c86379558.lkchenk1,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c86379558.lcheck1(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local g=cg:Select(tp,minct,1,nil)
if g:GetCount()==0 then break end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
end
......@@ -2,16 +2,8 @@
function c86379662.initial_effect(c)
aux.AddCodeList(c,20038)
--link summon
Exlink.AddLinkProcedure(c,nil,7,nil,c86379662.mattg,c86379662.matval,LOCATION_ONFIELD,LOCATION_ONFIELD)
c:EnableReviveLimit()
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(c86379662.lkcon1)
e0:SetOperation(c86379662.lkop1)
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
--Remove
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(86379662,0))
......@@ -53,76 +45,12 @@ function c86379662.initial_effect(c)
e4:SetValue(c86379662.efilter)
c:RegisterEffect(e4)
end
--
function c86379662.lkfilter1(c,lc,tp)
local flag=c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and c:IsControler(tp)
if c:IsType(TYPE_MONSTER) then
return flag
else
return c:IsFaceup() and c:IsType(TYPE_SPELL)
end
end
function c86379662.lvfilter1(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else
return 1
end
function c86379662.mattg(e,c)
return c:IsType(TYPE_SPELL) and c:IsOnField() and c:IsFaceup()
end
function c86379662.lcheck1(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(c86379662.lvfilter1,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function c86379662.lkchenk1(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=c86379662.lcheck1(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c86379662.lkchenk1,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
function c86379662.lkcon1(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(c86379662.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
local pc=pe:GetHandler()
if not mg:IsContains(pc) then return false end
sg:AddCard(pc)
end
local ct=sg:GetCount()
local minc=7
local maxc=8
if ct>maxc then return false end
return (c86379662.lcheck1(tp,sg,c,minc,ct) or mg:IsExists(c86379662.lkchenk1,1,nil,tp,sg,mg,c,ct,minc,maxc))
end
function c86379662.lkop1(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(c86379662.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
sg:AddCard(pe:GetHandler())
end
local ct=sg:GetCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
sg:Select(tp,ct,ct,nil)
local minc=7
local maxc=8
for i=ct,maxc-1 do
local cg=mg:Filter(c86379662.lkchenk1,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c86379662.lcheck1(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local g=cg:Select(tp,minct,1,nil)
if g:GetCount()==0 then break end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
function c86379662.matval(e,lc,mg,c,tp)
if e:GetHandler()~=lc then return false,nil end
return true,not mg or mg
end
--
function c86379662.rmcon(e,tp,eg,ep,ev,re,r,rp)
......
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