--Blue Magician function c249001056.initial_effect(c) aux.AddCodeList(c,249001056) c:SetUniqueOnField(1,0,249001056) --special summon self 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(c249001056.spcon1) e1:SetOperation(c249001056.spop1) c:RegisterEffect(e1) --cannot use as material local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetOperation(c249001056.matlimit) c:RegisterEffect(e2) local e3=e2:Clone() e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e3) local e4=e2:Clone() e4:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e4) --special summmon other local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetType(EFFECT_TYPE_IGNITION) e5:SetCountLimit(1) e5:SetRange(LOCATION_MZONE) e5:SetTarget(c249001056.target) e5:SetOperation(c249001056.operation) c:RegisterEffect(e5) --special summon self from deck local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_FIELD) e6:SetCode(EFFECT_SPSUMMON_PROC) e6:SetProperty(EFFECT_FLAG_UNCOPYABLE) e6:SetRange(LOCATION_DECK) e6:SetCondition(c249001056.spcon2) e6:SetOperation(c249001056.spop2) c:RegisterEffect(e6) --draw local e7=Effect.CreateEffect(c) e7:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e7:SetDescription(aux.Stringid(73594093,1)) e7:SetType(EFFECT_TYPE_IGNITION) e7:SetRange(LOCATION_REMOVED) e7:SetCondition(aux.exccon) e7:SetCountLimit(1,249001056) e7:SetTarget(c249001056.tdtg) e7:SetOperation(c249001056.tdop) c:RegisterEffect(e7) end function c249001056.spcon1(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(aux.IsCodeListed,tp,LOCATION_HAND,0,1,c,249001056) end function c249001056.spop1(e,tp,eg,ep,ev,re,r,rp,c) local tp=c:GetControler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,aux.IsCodeListed,tp,LOCATION_HAND,0,1,1,c,249001056) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) end function c249001056.matlimit(e,tp,eg,ep,ev,re,r,rp) aux.CannotBeEDMaterial(e:GetHandler(),nil,LOCATION_MZONE,false,RESETS_STANDARD+RESET_PHASE+PHASE_END) end function c249001056.spfilter(c,e,tp) return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c249001056.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c249001056.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK) end function c249001056.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c249001056.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then if Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE) and Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0,nil)>Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE,nil) then local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) end Duel.SpecialSummonComplete() end end function c249001056.spcon2(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(aux.IsCodeListed,tp,LOCATION_HAND,0,2,c,249001056) end function c249001056.spop2(e,tp,eg,ep,ev,re,r,rp,c) local tp=c:GetControler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,aux.IsCodeListed,tp,LOCATION_HAND,0,2,2,c,249001056) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) Duel.ShuffleDeck(tp) end function c249001056.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToDeck() and Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c249001056.tdop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,0,REASON_EFFECT)~=0 and c:IsLocation(LOCATION_DECK) then Duel.ShuffleDeck(tp) Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end end