Commit 19b03333 authored by TanakaKotoha's avatar TanakaKotoha

Mercury233

parent 2fcc4775
......@@ -113,18 +113,19 @@ end
if cm then
function cm.initial_effect(c)
--link summon
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_CYBERSE+RACE_MACHINE),2,2)
c:EnableReviveLimit()
aux.AddLinkProcedure(c,cm.lfilter(c:GetControler()),2,2)
--extra link
local e0=Effect.CreateEffect(c)
e0:SetDescription(aux.Stringid(12035010,0))
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetRange(LOCATION_EXTRA)
e0:SetTarget(cm.mattg)
e0:SetCode(EFFECT_EXTRA_LINK_MATERIAL)
e0:SetTargetRange(LOCATION_SZONE,0)
e0:SetValue(cm.matval)
c:RegisterEffect(e0)
e0:SetCondition(cm.lkcon)
e0:SetOperation(cm.lkop)
e0:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e0)
--
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND)
......@@ -137,6 +138,79 @@ function cm.initial_effect(c)
e1:SetOperation(cm.thop)
c:RegisterEffect(e1)
end
function cm.cknfilter(c)
return not c:IsDisabled()
end
function cm.lkfilter(c,lc,tp)
local flag=c:IsFaceup() and c:IsCanBeLinkMaterial(lc)
if c:IsType(TYPE_MONSTER) then
return flag and c:IsLinkRace(RACE_CYBERSE+RACE_MACHINE)
else
return c:IsFaceup() and c:IsType(TYPE_TRAP) and not Duel.IsExistingMatchingCard(cm.cknfilter,tp,0,LOCATION_SZONE,1,nil)
end
end
function cm.lvfilter(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else
return 1
end
end
--
function cm.lcheck(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(cm.lvfilter,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function cm.lkchenk(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=cm.lcheck(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(cm.lkchenk,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
function cm.lkcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
local mg=Duel.GetMatchingGroup(cm.lkfilter,tp,LOCATION_ONFIELD,0,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=2
local maxc=2
if ct>maxc then return false end
return cm.lcheck(tp,sg,c,minc,ct) or mg:IsExists(cm.lkchenk,1,nil,tp,sg,mg,c,ct,minc,maxc)
end
function cm.lkop(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(cm.lkfilter,tp,LOCATION_ONFIELD,0,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=2
local maxc=2
for i=ct,maxc-1 do
local cg=mg:Filter(cm.lkchenk,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if cm.lcheck(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,aux.Stringid(12035010,0)) 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 cm.thcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsSummonType(SUMMON_TYPE_LINK)
......@@ -146,7 +220,7 @@ function cm.thfilter(c,tp,setable)
end
function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local g=e:GetHandler():GetMutualLinkedGroup()
local setable=g:IsExists(Card.IsCode,1,nil,m+1) and true or false
local setable=g:IsExists(Card.IsCode,1,nil,m-1) and true or false
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and cm.thfilter(chkc,tp,setable) end
if chk==0 then return Duel.IsExistingTarget(cm.thfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil,tp,setable) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
......@@ -167,17 +241,5 @@ function cm.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.SSet(tp,tc)
end
end
function cm.lfilter(tp)
return function(c)
return c:IsLinkRace(RACE_CYBERSE+RACE_MACHINE) or (c:IsType(TYPE_TRAP) and c:IsControler(tp))
end
end
function cm.matval(e,c,mg)
return c:IsCode(m)
end
function cm.mattg(e,c)
return c:IsFaceup() and c:IsType(TYPE_TRAP)
end
---------------------
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