--Moonvale Guidance function c10505098.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,10505098) e1:SetTarget(c10505098.actg) e1:SetOperation(c10505098.activate) c:RegisterEffect(e1) --extra summon local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_SZONE) e2:SetCode(EFFECT_EXTRA_SUMMON_COUNT) e2:SetTargetRange(LOCATION_HAND+LOCATION_MZONE,0) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x1a4)) c:RegisterEffect(e2) --Ritual Summon local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetDescription(aux.Stringid(10505098,1)) e4:SetType(EFFECT_TYPE_IGNITION+EFFECT_TYPE_QUICK_O) e4:SetRange(LOCATION_SZONE) e4:SetCost(c10505098.spcost) e4:SetTarget(c10505098.target) e4:SetOperation(c10505098.operation) c:RegisterEffect(e4) end function c10505098.tgfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x1a4) and c:IsAbleToGrave() end function c10505098.actg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c10505098.tgfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function c10505098.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(c10505098.tgfilter,tp,LOCATION_DECK,0,nil) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(10505098,0)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=g:Select(tp,1,1,nil) Duel.SendtoGrave(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function c10505098.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 c10505098.filter(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(c10505098.mfilterf,1,nil,tp,mg,c) end end function c10505098.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 c10505098.target(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(c10505098.filter,tp,LOCATION_HAND,0,1,nil,e,tp,mg,ft) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function c10505098.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,c10505098.filter,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,c10505098.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