Commit b8ae81ab authored by Huangnan's avatar Huangnan

Merge branch 'undefined' into 'master'

add--Mimighoul Charm

See merge request !101
parents e9176dd5 015c2840
--Mimighoul Charm
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--SpecialSummon&Remove
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_REMOVE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_CHANGE_POS)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(2,id)
e2:SetCondition(s.spcon)
e2:SetTarget(s.sptg)
e2:SetOperation(s.spop)
c:RegisterEffect(e2)
end
function s.cfilter2(c,tp,e)
return c:IsPreviousPosition(POS_FACEDOWN) and c:IsFaceup() and c:IsControler(1-tp) and c:IsSetCard(0x1b7)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(s.cfilter2,1,nil,tp) and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2)
end
function s.spfilter(c,e,tp)
return c:IsFacedown() and ((c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0) or c:IsAbleToRemove())
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.spfilter,tp,0,LOCATION_EXTRA,1,nil,e,tp) and e:GetHandler():GetFlagEffect(id)==0 end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
e:GetHandler():RegisterFlagEffect(id,RESET_CHAIN,0,1)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsFacedown,tp,0,LOCATION_EXTRA,nil)
if #g==0 then return end
Duel.ShuffleExtra(1-tp)
local tg=g:RandomSelect(1-tp,1)
Duel.ConfirmCards(1-tp,tg)
local tc=tg:GetFirst()
if tc:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,tc)>0 then
if Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_TRIGGER)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
else
Duel.Remove(tc,POS_FACEUP,REASON_EFFECT)
end
end
\ No newline at end of file
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