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)
--atk
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetValue(c25501.atkval)
c:RegisterEffect(e2)
--cannot attack
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
e4:SetOperation(c25501.atklimit)
c:RegisterEffect(e4)
--immune trap
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e6:SetRange(LOCATION_MZONE)
e6:SetCode(EFFECT_IMMUNE_EFFECT)
e6:SetCondition(c25501.econ)
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)
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)
end
--
function c25501.atkval(e,c)
return c:GetLinkedGroupCount()*1000
end
function c25501.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c25501.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c25501.efilter(e,te)
return te:IsActiveType(TYPE_TRAP)
end
--花与妖的连结✿风见幽香
function c25501.initial_effect(c)
--link summon
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)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetValue(c25501.atkval)
c:RegisterEffect(e2)
--cannot attack
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
e4:SetOperation(c25501.atklimit)
c:RegisterEffect(e4)
--immune trap
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e6:SetRange(LOCATION_MZONE)
e6:SetCode(EFFECT_IMMUNE_EFFECT)
e6:SetCondition(c25501.econ)
e6:SetValue(c25501.efilter)
c:RegisterEffect(e6)
end
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.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 c25501.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c25501.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c25501.efilter(e,te)
return te:IsActiveType(TYPE_TRAP)
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)
--moon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(LOCATION_SZONE,0)
e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x257))
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_ONFIELD,0)
e2:SetTarget(c86379558.indes)
e2:SetValue(1)
c:RegisterEffect(e2)
--lp
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(86379558,0))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_DESTROYED)
e3:SetTarget(c86379558.lptg)
e3:SetOperation(c86379558.lpop)
c:RegisterEffect(e3)
end
--
function c86379558.indes(e,c)
return c:IsFaceup() and c:IsSetCard(0x257) and c:IsType(TYPE_SPELL+TYPE_TRAP)
end
--
function c86379558.lptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReason(REASON_EFFECT) end
end
function c86379558.lpop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCountLimit(1)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetOperation(c86379558.damop)
Duel.RegisterEffect(e1,tp)
end
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
--蓬莱-永夜的隐者✿八意永琳
function c86379558.initial_effect(c)
--link summon
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)
e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(LOCATION_SZONE,0)
e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x257))
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_ONFIELD,0)
e2:SetTarget(c86379558.indes)
e2:SetValue(1)
c:RegisterEffect(e2)
--lp
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(86379558,0))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_DESTROYED)
e3:SetTarget(c86379558.lptg)
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)
end
--
function c86379558.lptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReason(REASON_EFFECT) end
end
function c86379558.lpop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCountLimit(1)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetOperation(c86379558.damop)
Duel.RegisterEffect(e1,tp)
end
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 c86379662.initial_effect(c)
aux.AddCodeList(c,20038)
--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(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))
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_MAIN_END)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c86379662.rmcon)
e1:SetCost(c86379662.rmcost)
e1:SetTarget(c86379662.rmtg)
e1:SetOperation(c86379662.rmop)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(86379662,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_REMOVED)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e2:SetCondition(c86379662.gcon1)
e2:SetTarget(c86379662.gtg)
e2:SetOperation(c86379662.gop)
c:RegisterEffect(e2)
--
local e3=e2:Clone()
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetCondition(c86379662.gcon2)
c:RegisterEffect(e3)
--immune trap
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_IMMUNE_EFFECT)
e4:SetCondition(c86379662.econ)
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
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)
end
--
function c86379662.rmcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
end
function c86379662.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
if Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST+REASON_TEMPORARY)~=0 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetLabelObject(e:GetHandler())
e1:SetCountLimit(1)
e1:SetOperation(c86379662.retop)
Duel.RegisterEffect(e1,tp)
end
end
function c86379662.retop(e,tp,eg,ep,ev,re,r,rp)
Duel.ReturnToField(e:GetLabelObject())
end
function c86379662.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_GRAVE)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE)
end
function c86379662.rmop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,4,nil)
if g:GetCount()>0 then
Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
end
end
--
function c86379662.gconfilter(c)
return aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gcon1(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)<4
end
function c86379662.gcon2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)>=4
end
function c86379662.gfilter(c)
return c:IsAbleToHand() and aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_ONFIELD) and c86379662.gfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c86379662.gop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
--
function c86379662.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c86379662.efilter(e,te)
return te:IsActiveType(TYPE_SPELL)
end
--境界的妖怪✿八云紫
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()
--Remove
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(86379662,0))
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_MAIN_END)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c86379662.rmcon)
e1:SetCost(c86379662.rmcost)
e1:SetTarget(c86379662.rmtg)
e1:SetOperation(c86379662.rmop)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(86379662,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_REMOVED)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e2:SetCondition(c86379662.gcon1)
e2:SetTarget(c86379662.gtg)
e2:SetOperation(c86379662.gop)
c:RegisterEffect(e2)
--
local e3=e2:Clone()
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetCondition(c86379662.gcon2)
c:RegisterEffect(e3)
--immune trap
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_IMMUNE_EFFECT)
e4:SetCondition(c86379662.econ)
e4:SetValue(c86379662.efilter)
c:RegisterEffect(e4)
end
function c86379662.mattg(e,c)
return c:IsType(TYPE_SPELL) and c:IsOnField() and c:IsFaceup()
end
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)
return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
end
function c86379662.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
if Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST+REASON_TEMPORARY)~=0 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetLabelObject(e:GetHandler())
e1:SetCountLimit(1)
e1:SetOperation(c86379662.retop)
Duel.RegisterEffect(e1,tp)
end
end
function c86379662.retop(e,tp,eg,ep,ev,re,r,rp)
Duel.ReturnToField(e:GetLabelObject())
end
function c86379662.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_GRAVE)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE)
end
function c86379662.rmop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,4,nil)
if g:GetCount()>0 then
Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
end
end
--
function c86379662.gconfilter(c)
return aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gcon1(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)<4
end
function c86379662.gcon2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)>=4
end
function c86379662.gfilter(c)
return c:IsAbleToHand() and aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_ONFIELD) and c86379662.gfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c86379662.gop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
--
function c86379662.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c86379662.efilter(e,te)
return te:IsActiveType(TYPE_SPELL)
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