Commit 194c5f18 authored by YuGiOhMoDDeR's avatar YuGiOhMoDDeR
parent 16c605be
--Lightsworn Sanctuary
function c52665542.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(52665542,0))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCountLimit(1)
e2:SetRange(LOCATION_SZONE)
e2:SetCost(c52665542.cost)
e2:SetTarget(c52665542.target)
e2:SetOperation(c52665542.activate)
c:RegisterEffect(e2)
--add counter
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetRange(LOCATION_SZONE)
e3:SetOperation(c52665542.acop)
c:RegisterEffect(e3)
--destroy replace
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e4:SetCode(EFFECT_DESTROY_REPLACE)
e4:SetRange(LOCATION_SZONE)
e4:SetTarget(c52665542.destg)
e4:SetValue(c52665542.value)
e4:SetOperation(c52665542.desop)
c:RegisterEffect(e4)
end
function c52665542.costfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x38) and c:IsAbleToGraveAsCost()
end
function c52665542.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c52665542.costfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
local g=Duel.GetFieldGroup(tp,LOCATION_HAND,0)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local sg=g:FilterSelect(tp,c52665542.costfilter,1,1,nil)
e:SetLabelObject(sg:GetFirst())
Duel.SendtoGrave(sg,REASON_COST)
end
function c52665542.tgfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x38) and c:IsAbleToHand()
end
function c52665542.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetLabelObject()
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c52665542.tgfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c52665542.tgfilter,tp,LOCATION_GRAVE,0,1,c) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg=Duel.SelectTarget(tp,c52665542.tgfilter,tp,LOCATION_GRAVE,0,1,1,c)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,sg,sg:GetCount(),0,0)
end
function c52665542.activate(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tc)
end
end
function c52665542.cfilter(c,tp)
return c:GetPreviousLocation()==LOCATION_DECK and c:GetPreviousControler()==tp
end
function c52665542.acop(e,tp,eg,ep,ev,re,r,rp)
if eg:IsExists(c52665542.cfilter,1,nil,tp) then
e:GetHandler():AddCounter(0x5,1)
end
end
function c52665542.dfilter(c,tp)
return c:IsFaceup() and c:IsLocation(LOCATION_ONFIELD)
and c:IsSetCard(0x38) and c:IsControler(tp)
end
function c52665542.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local count=eg:FilterCount(c52665542.dfilter,nil,tp)
e:SetLabel(count)
return count>0 and Duel.IsCanRemoveCounter(tp,1,0,0x5,count*2,REASON_EFFECT)
end
return Duel.SelectYesNo(tp,aux.Stringid(52665542,1))
end
function c52665542.value(e,c)
return c:IsFaceup() and c:IsLocation(LOCATION_ONFIELD)
and c:IsSetCard(0x38) and c:IsControler(e:GetHandlerPlayer())
end
function c52665542.desop(e,tp,eg,ep,ev,re,r,rp)
local count=e:GetLabel()
Duel.RemoveCounter(tp,1,0,0x5,count*2,REASON_EFFECT)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment