--Magical Vortex Draw function c249001059.initial_effect(c) aux.AddCodeList(c,249001056) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,249001059) e1:SetCondition(c249001059.condition) e1:SetTarget(c249001059.target) e1:SetOperation(c249001059.activate) c:RegisterEffect(e1) --draw local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(63362460,1)) e2:SetCategory(CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,249001059) e2:SetCondition(c249001059.drcon) e2:SetCost(c249001059.drcost) e2:SetTarget(c249001059.target) e2:SetOperation(c249001059.operation) c:RegisterEffect(e2) end function c249001059.cfilter(c) return c:IsFaceup() and c:IsCode(249001056) end function c249001059.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(c249001059.cfilter,tp,LOCATION_ONFIELD,0,1,nil) end function c249001059.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) end function c249001059.activate(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) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK) e1:SetTarget(aux.TargetBoolFunction(Card.IsCode,249001056)) e1:SetTargetRange(LOCATION_MZONE,0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c249001059.drcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)==0 and aux.exccon(e) end function c249001059.cfilter2(c) return aux.IsCodeListed(c,249001056) and c:IsAbleToRemoveAsCost() end function c249001059.drcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsAbleToRemoveAsCost() and Duel.IsExistingMatchingCard(c249001059.cfilter2,tp,LOCATION_GRAVE,0,1,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249001059.cfilter2,tp,LOCATION_GRAVE,0,1,1,c) g:AddCard(c) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c249001059.operation(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