--Mysterious Phoenix function c53313915.initial_effect(c) --battle indestructable local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1) e3:SetValue(function(e,re,r,rp) return bit.band(r,REASON_BATTLE)~=0 end) c:RegisterEffect(e3) --lv change local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(53313915,0)) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_MZONE) e4:SetCountLimit(1) e4:SetTarget(c53313915.lvtg) e4:SetOperation(c53313915.lvop) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(53313915,1)) e5:SetCategory(CATEGORY_DRAW) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e5:SetCode(EVENT_BATTLE_DESTROYED) e5:SetCondition(c53313915.lvcon) e5:SetTarget(c53313915.lvtg2) e5:SetOperation(c53313915.lvop2) c:RegisterEffect(e5) end function c53313915.indescon(e,tp,eg,ep,ev,re,r,rp) local seq=e:GetHandler():GetSequence() local tc=Duel.GetFieldCard(e:GetHandlerPlayer(),LOCATION_SZONE,13-seq) return tc and tc:IsSetCard(0xCF6) end function c53313915.repfilter(c,tp) return c:IsSetCard(0xCF6) and c:IsControler(tp) and c:IsOnField() and c:IsReason(REASON_BATTLE) and c:GetFlagEffect(53313915)==0 end function c53313915.reptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return eg:IsExists(c53313915.repfilter,1,nil,tp) end local g=eg:Filter(c53313915.repfilter,nil,tp) local tc=g:GetFirst() while tc do tc:RegisterFlagEffect(53313915,RESET_EVENT+0x1fc0000+RESET_PHASE+RESET_END,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(53313915,0)) tc=g:GetNext() end e:GetLabelObject():Clear() e:GetLabelObject():Merge(g) return true end function c53313915.repval(e,c) local g=e:GetLabelObject() return g:IsContains(c) end function c53313915.cfilter(c,tp) return c:IsControler(tp) and c:GetSummonType()==SUMMON_TYPE_PENDULUM and c:IsCode(53313915) end function c53313915.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c53313915.cfilter,1,nil,tp) end function c53313915.filter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() end function c53313915.spfilter(c,e,tp) return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c53313915.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c53313915.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.IsExistingMatchingCard(c53313915.filter,tp,0,LOCATION_ONFIELD,1,c) end local sg=Duel.GetMatchingGroup(c53313915.filter,tp,0,LOCATION_ONFIELD,c) Duel.SetOperationInfo(0,CATEGORY_TOHAND,sg,sg:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c53313915.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local sg=Duel.GetMatchingGroup(c53313915.filter,tp,0,LOCATION_ONFIELD,nil) if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c53313915.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end end function c53313915.retfilter(c) return c:IsFaceup() and c:IsLevelAbove(1) end function c53313915.lvtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c53313915.retfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c53313915.retfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,c53313915.retfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) local tc=g:GetFirst() local op=0 if tc:GetLevel()==1 then op=Duel.SelectOption(tp,aux.Stringid(53313915,1))end e:SetLabel(op) end function c53313915.lvop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetReset(RESET_EVENT+0x1fe0000) if e:GetLabel()==0 then e1:SetValue(1) end tc:RegisterEffect(e1) end end function c53313915.lvcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE) end function c53313915.lvtg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c53313915.retfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c53313915.retfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,c53313915.retfilter,tp,LOCATION_MZONE,0,1,1,nil) local tc=g:GetFirst() local op=0 if tc:GetLevel()==1 then op=Duel.SelectOption(tp,aux.Stringid(53313915,1))end e:SetLabel(op) end function c53313915.lvop2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetReset(RESET_EVENT+0x1fe0000) if e:GetLabel()==0 then e1:SetValue(1) end tc:RegisterEffect(e1) end end