--Monkastery Arte - Switchup local ref,id=GetID() Duel.LoadScript("Monkastery.lua") function ref.initial_effect(c) --Act in Hand local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetCode(EFFECT_TRAP_ACT_IN_HAND) e0:SetCondition(ref.handcon) c:RegisterEffect(e0) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCost(ref.actcost) e1:SetTarget(ref.acttg) e1:SetOperation(ref.actop) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER_E) c:RegisterEffect(e1) --Continue local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_TO_GRAVE) e2:SetTarget(ref.sstg) e2:SetOperation(ref.ssop) c:RegisterEffect(e2) end --Act in Hand function ref.handcon(e) local chk,eg,ep,ev,re,r,rp = Duel.CheckEvent(EVENT_CHAINING,true) return chk and rp~=e:GetHandlerPlayer() end --Activate function ref.actcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,Card.IsAbleToGraveAsCost,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,c) Duel.SendtoGrave(g,REASON_COST) end function ref.ssfilter(c,e,tp) return Monkastery.Is(c) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function ref.acttg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(ref.ssfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function ref.actop(e,tp,eg,ep,ev,re,r,rp) if not (Duel.GetLocationCount(tp,LOCATION_MZONE)>0) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,ref.ssfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end --Continue function ref.ss2filter(c,e,tp) return Monkastery.UsedFilter(c,id) and ref.ssfilter(c,e,tp) end function ref.sstg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and ref.ss2filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(ref.ss2filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,ref.ss2filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,#g,tp,LOCATION_GRAVE) end function ref.ssop(e,tp,eg,ep,ev,re,r,rp) if not (Duel.GetLocationCount(tp,LOCATION_MZONE)>0) then return end local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end