function c500311028.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND+LOCATION_GRAVE) e1:SetCondition(c500311028.spcon) e1:SetOperation(c500311028.spop) c:RegisterEffect(e1) --Activate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(500311028,0)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCountLimit(1,500311028) e2:SetCondition(c500311028.descon) e2:SetTarget(c500311028.destg) e2:SetOperation(c500311028.desop) e2:SetLabelObject(e1) c:RegisterEffect(e2) --effect local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(500311028,0)) e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_HAND) e3:SetCountLimit(1,500311028) e3:SetCost(c500311028.cost) e3:SetTarget(c500311028.tg) e3:SetOperation(c500311028.op) c:RegisterEffect(e3) end function c500311028.spfilter(c) return c:IsRace(RACE_FIEND) and c:IsDiscardable() end function c500311028.spcon(e,c) if c==nil then return true end local tp=c:GetControler() if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return false end local g=Duel.GetMatchingGroup(c500311028.spfilter,tp,LOCATION_HAND,0,nil) if not c:IsAbleToGraveAsCost() then g:RemoveCard(c) end return g:CheckWithSumGreater(Card.GetLevel,9) and Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end function c500311028.spop(e,tp,eg,ep,ev,re,r,rp,c) local g=Duel.GetMatchingGroup(c500311028.spfilter,c:GetControler(),LOCATION_HAND,0,nil) if not c:IsAbleToGrave() then g:RemoveCard(c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=g:SelectWithSumGreater(tp,Card.GetLevel,9) Duel.SendtoGrave(sg,REASON_EFFECT) end function c500311028.descon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL and re==e:GetLabelObject() and e:GetHandler():GetSummonLocation()==LOCATION_HAND end function c500311028.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDestructable,tp,LOCATION_SZONE,LOCATION_SZONE,1,nil) end local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_SZONE,LOCATION_SZONE,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c500311028.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_SZONE,LOCATION_SZONE,nil) if g:GetCount()>0 then Duel.Destroy(g,REASON_EFFECT) end end function c500311028.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end Duel.SendtoGrave(e:GetHandler(),REASON_COST) end function c500311028.filter(c) return c:IsSetCard(0x485a) and c:GetCode()~=500311028 and c:IsAbleToHand() end function c500311028.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c500311028.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c500311028.op(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c500311028.filter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end