--Moonvale Magician function c10505082.initial_effect(c) c:SetSPSummonOnce(10505082) --spsummon 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(c10505082.spcon) e1:SetOperation(c10505082.spop) c:RegisterEffect(e1) --spsummon success local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(10505082,1)) e2:SetCategory(CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DELAY) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetTarget(c10505082.drtarg) e2:SetOperation(c10505082.drop) c:RegisterEffect(e2) --tohand local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e3:SetCode(EVENT_RELEASE) e3:SetCondition(c10505082.thcon) e3:SetTarget(c10505082.thtg) e3:SetOperation(c10505082.thop) c:RegisterEffect(e3) end function c10505082.spfilter(c) return c:IsFaceup() and c:IsSetCard(0x1a5) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToGraveAsCost() end function c10505082.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(c10505082.spfilter,c:GetControler(),LOCATION_ONFIELD,0,1,nil) end function c10505082.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c10505082.spfilter,tp,LOCATION_SZONE,0,1,1,nil) Duel.SendtoGrave(g,nil,REASON_COST) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x47e0000) e1:SetValue(LOCATION_REMOVED) c:RegisterEffect(e1,true) end function c10505082.drtarg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c10505082.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c10505082.thcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_RITUAL) end function c10505082.thfilter(c) return c:IsSetCard(0x1a4) and c:IsType(TYPE_MONSTER) and not c:IsCode(10505082) and c:IsAbleToHand() end function c10505082.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c10505082.thfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c10505082.thfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,c10505082.thfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function c10505082.thop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end