Commit 9c92db2c authored by wind2009's avatar wind2009

Merge branch 'patch-5' into 'master'

Add サモンカウンター

See merge request !256
parents 0b1f21fb e59f6c13
Pipeline #42384 passed with stages
in 1 minute and 43 seconds
--サモンカウンター
local s,id,o=GetID()
function s.initial_effect(c)
c:EnableCounterPermit(0x4c)
c:SetCounterLimit(0x4c,4)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--counter
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetRange(LOCATION_SZONE)
e2:SetTarget(s.cttg)
e2:SetOperation(s.ctop)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e3)
--tograve
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,0))
e4:SetCategory(CATEGORY_TOGRAVE)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_CUSTOM+id)
e4:SetProperty(EFFECT_FLAG_DELAY)
e4:SetRange(LOCATION_SZONE)
e4:SetTarget(s.tgtg)
e4:SetOperation(s.tgop)
c:RegisterEffect(e4)
end
function s.cttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsCanAddCounter(0x4c,1) end
end
function s.ctop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
c:AddCounter(0x4c,1)
if c:GetCounter(0x4c)==4 then
Duel.RaiseEvent(c,EVENT_CUSTOM+id,e,0,tp,tp,0)
end
end
function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetCounter(0x4c)==4 end
local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,g:GetCount(),0,0)
end
function s.tgop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() then
local ct=c:GetCounter(0x4c)
c:RemoveCounter(tp,0x4c,ct,REASON_EFFECT)
local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
Duel.SendtoGrave(g,REASON_EFFECT)
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