Skip to content

Instantly share code, notes, and snippets.

@windikite
Created March 24, 2016 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windikite/31738db0a808767e8fd1 to your computer and use it in GitHub Desktop.
Save windikite/31738db0a808767e8fd1 to your computer and use it in GitHub Desktop.
function c13713703.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c13713703.target)
e1:SetOperation(c13713703.activate)
c:RegisterEffect(e1)
--Activate from grave
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(13713703,0))
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_GRAVE)
e2:SetCost(c13713703.cost2)
e2:SetTarget(c13713703.target2)
e2:SetOperation(c13713703.operation2)
c:RegisterEffect(e2)
end
--add to hand
function c13713703.filter(c)
return ((c:IsSetCard(0xbf) and c:IsAbleToHand()) or (c:IsSetCard(0xc0) and c:IsAbleToHand()))
or (c:IsRace(RACE_SPELLCASTER) and c:IsDefenceBelow(1500) and c:IsAbleToHand())
end
function c13713703.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c13713703.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c13713703.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c13713703.filter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
--change attribute
--check if can banish as cost
function c13713703.cost2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
--check target
function c13713703.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c13713703.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c13713703.filter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c13713703.filter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c13713703.filter2(c)
return c:IsFaceup()
end
function c13713703.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
local e2=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e2:SetValue(c13713703.value)
e2:SetLabelObject(e2)
tc:RegisterEffect(e2)
end
end
function c13713703.value(e,c)
return e:GetLabel()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment