Commit ec63ec63 authored by 八宫一月's avatar 八宫一月

add ヤミー☆サプライズ

parent 7dff4c9a
--ヤミー☆サプライズ
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function s.thfilter1(c)
return c:IsFaceup() and c:IsRace(RACE_BEAST) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand()
end
function s.spfilter(c,e,tp)
return c:IsSetCard(0x2c8) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP)
end
function s.thfilter2(c)
return c:IsFaceupEx() and c:IsType(TYPE_FIELD) and c:IsAbleToHand()
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local b1=Duel.IsExistingTarget(s.thfilter1,tp,LOCATION_MZONE,0,2,nil) and Duel.IsExistingTarget(Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,2,nil) and (Duel.GetFlagEffect(tp,id)==0 or not e:IsCostChecked())
local b2=(Duel.GetFlagEffect(tp,id+o)==0 or not e:IsCostChecked()) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp)
local b3=(Duel.GetFlagEffect(tp,id+2*o)==0 or not e:IsCostChecked()) and Duel.IsExistingMatchingCard(s.thfilter2,tp,LOCATION_FZONE+LOCATION_GRAVE,0,1,nil)
if chk==0 then return b1 or b2 or b3 end
local op=0
local op=aux.SelectFromOptions(tp,
{b1,aux.Stringid(id,1)},
{b2,aux.Stringid(id,2)},
{b3,aux.Stringid(id,3)})
e:SetLabel(op)
if op==1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g1=Duel.SelectTarget(tp,s.thfilter1,tp,LOCATION_MZONE,0,2,2,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g2=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,2,2,nil)
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g1,g1:GetCount(),0,0)
if e:IsCostChecked() then
e:SetCategory(CATEGORY_TOHAND)
e:SetProperty(EFFECT_FLAG_CARD_TARGET)
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,0,1)
end
elseif op==2 then
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE)
if e:IsCostChecked() then
e:SetCategory(CATEGORY_SPECIAL_SUMMON)
Duel.RegisterFlagEffect(tp,id+o,RESET_PHASE+PHASE_END,0,1)
end
else
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_FZONE+LOCATION_GRAVE)
if e:IsCostChecked() then
e:SetCategory(CATEGORY_TOHAND)
Duel.RegisterFlagEffect(tp,id+2*o,RESET_PHASE+PHASE_END,0,1)
end
end
end
function s.tffilter(c,tp)
return c:IsSetCard(0x2c8) and c:IsType(TYPE_FIELD+TYPE_SPELL)
and not c:IsForbidden() and c:CheckUniqueOnField(tp)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local op=e:GetLabel()
if op==1 then
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tg=g:Filter(Card.IsRelateToEffect,nil,e)
if tg:GetCount()>0 then
Duel.SendtoHand(tg,nil,REASON_EFFECT)
end
elseif op==2 then
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then
--cannot atk directly this turn
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
Duel.SpecialSummonComplete()
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tc=Duel.SelectMatchingCard(tp,s.thfilter2,tp,LOCATION_FZONE+LOCATION_GRAVE,0,1,1,nil):GetFirst()
if tc then
if Duel.SendtoHand(tc,nil,REASON_EFFECT)~=0 then
Duel.ConfirmCards(1-tp,tc)
if Duel.IsExistingMatchingCard(s.tffilter,tp,LOCATION_HAND,0,1,nil,tp) and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local tfc=Duel.SelectMatchingCard(tp,s.tffilter,tp,LOCATION_HAND,0,1,1,nil,tp):GetFirst()
local fc=Duel.GetFieldCard(tp,LOCATION_FZONE,0)
if fc then
Duel.SendtoGrave(fc,REASON_RULE)
Duel.BreakEffect()
end
if tfc then
Duel.MoveToField(tfc,tp,tp,LOCATION_FZONE,POS_FACEUP,true)
end
end
end
end
end
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