--Moonvale Destiny function c10505094.initial_effect(c) --shuffle and draw local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,10505094) e1:SetTarget(c10505094.target) c:RegisterEffect(e1) --indes local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetRange(LOCATION_SZONE) e2:SetTargetRange(LOCATION_SZONE,0) e2:SetTarget(c10505094.indtg) e2:SetValue(1) c:RegisterEffect(e2) --Ritual Summon local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetDescription(aux.Stringid(10505094,1)) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetRange(LOCATION_SZONE) e3:SetCode(EVENT_FREE_CHAIN) e3:SetCost(c10505094.spcost) e3:SetTarget(c10505094.target3) e3:SetOperation(c10505094.operation) c:RegisterEffect(e3) end function c10505094.tdfilter(c) return c:IsSetCard(0x1a4) or c:IsSetCard(0x1a5) and c:IsAbleToDeck() end function c10505094.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c10505094.tdfilter(chkc,e,tp) end if chk==0 then return true end if Duel.IsExistingTarget(c10505094.tdfilter,tp,LOCATION_GRAVE,0,2,nil,e,tp) and Duel.SelectYesNo(tp,aux.Stringid(10505094,0)) then e:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e:SetProperty(EFFECT_FLAG_CARD_TARGET) e:SetOperation(c10505094.activate) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,c10505094.tdfilter,tp,LOCATION_GRAVE,0,2,2,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) else e:SetCategory(0) e:SetProperty(0) e:SetOperation(nil) end end function c10505094.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if tg:GetCount()<=0 then return end Duel.SendtoDeck(tg,nil,0,REASON_EFFECT) Duel.ShuffleDeck(tp) Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end function c10505094.indtg(e,c) return c:IsSetCard(0x1a5) and c~=e:GetHandler() end function c10505094.spcost(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 c10505094.filter2(c,e,tp,m,ft) if not c:IsSetCard(0x1a4) or bit.band(c:GetType(),0x81)~=0x81 or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true) then return false end local mg=m:Filter(Card.IsCanBeRitualMaterial,c,c) if c.mat_filter then mg=mg:Filter(c.mat_filter,nil) end if ft>0 then return mg:CheckWithSumGreater(Card.GetRitualLevel,c:GetLevel(),c) else return ft>-1 and mg:IsExists(c10505094.mfilterf,1,nil,tp,mg,c) end end function c10505094.mfilterf(c,tp,mg,rc) if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) then Duel.SetSelectedCard(c) return mg:CheckWithSumGreater(Card.GetRitualLevel,rc:GetLevel(),rc) else return false end end function c10505094.target3(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local mg=Duel.GetRitualMaterial(tp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) return Duel.IsExistingMatchingCard(c10505094.filter2,tp,LOCATION_HAND,0,1,nil,e,tp,mg,ft) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function c10505094.operation(e,tp,eg,ep,ev,re,r,rp) local mg=Duel.GetRitualMaterial(tp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=Duel.SelectMatchingCard(tp,c10505094.filter2,tp,LOCATION_HAND,0,1,1,nil,e,tp,mg,ft) local tc=tg:GetFirst() if tc then mg=mg:Filter(Card.IsCanBeRitualMaterial,tc,tc) if tc.mat_filter then mg=mg:Filter(tc.mat_filter,nil) end local mat=nil if ft>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) mat=mg:SelectWithSumGreater(tp,Card.GetRitualLevel,tc:GetLevel(),tc) Duel.ReleaseRitualMaterial(mat) else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) mat=mg:FilterSelect(tp,c10505094.mfilterf,1,1,nil,tp,mg,tc) Duel.SetSelectedCard(mat) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local mat2=mg:SelectWithSumGreater(tp,Card.GetRitualLevel,tc:GetLevel(),tc) mat:Merge(mat2) tc:SetMaterial(mat) Duel.ReleaseRitualMaterial(mat) end Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() end end