--Mage-Guild Enchanter function c249000864.initial_effect(c) --atk up on normal summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(29716911,0)) e1:SetCategory(CATEGORY_ATKCHANGE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e1:SetTarget(c249000864.atktg) e1:SetOperation(c249000864.atkop) c:RegisterEffect(e1) --to hand local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e2:SetCategory(CATEGORY_TOHAND) e2:SetCode(EVENT_PHASE+PHASE_STANDBY) e2:SetRange(LOCATION_GRAVE) e2:SetCondition(c249000864.condition) e2:SetCost(c249000864.cost) e2:SetTarget(c249000864.target) e2:SetOperation(c249000864.operation) c:RegisterEffect(e2) --draw local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(18036057,0)) e3:SetCategory(CATEGORY_DRAW) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DELAY) e3:SetRange(LOCATION_MZONE) e3:SetCode(EVENT_BATTLE_DAMAGE) e3:SetCountLimit(1) e3:SetCondition(c249000864.condition2) e3:SetTarget(c249000864.target2) e3:SetOperation(c249000864.operation2) c:RegisterEffect(e3) end function c249000864.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local c=e:GetHandler() if chkc then return chkc:IsOnField() and chkc:IsControler(tp) and chkc:IsFaceup() and chkc~=c end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c249000864.atkfilter,tp,LOCATION_MZONE,0,1,1,c) end function c249000864.atkop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then c:SetCardTarget(tc) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_OWNER_RELATE+EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetRange(LOCATION_MZONE) e1:SetCondition(c249000864.rcon) e1:SetValue(800) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1,true) end end function c249000864.rcon(e) return e:GetOwner():IsHasCardTarget(e:GetHandler()) end function c249000864.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c249000864.costfilter(c) return c:IsSetCard(0x1F9) and c:IsAbleToDeckOrExtraAsCost() end function c249000864.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(c249000864.costfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,2,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249000864.costfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,2,2,c) Duel.SendtoDeck(g,nil,2,REASON_COST) end function c249000864.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToHand() end Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0) end function c249000864.operation(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT) end end function c249000864.condition2(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and eg:GetFirst():GetControler()==tp end function c249000864.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c249000864.operation2(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