--Monkastery Adherent local ref,id=GetID() Duel.LoadScript("Monkastery.lua") function ref.initial_effect(c) local e1,e2=Monkastery.SharedEffects(c) --Pop e1:SetCategory(CATEGORY_DESTROY) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(ref.destg) e1:SetOperation(ref.desop) c:RegisterEffect(e1) --Cycle e2:SetCategory(CATEGORY_HANDES+CATEGORY_DRAW) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetTarget(ref.drtg) e2:SetOperation(ref.drop) c:RegisterEffect(e2) end --Cycle function ref.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,1,tp,0) end function ref.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Draw(p,d,REASON_EFFECT)~=0 then Duel.BreakEffect() Duel.DiscardHand(p,Card.IsDiscardable,1,1,REASON_EFFECT,nil) end end --Destroy function ref.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsType(TYPE_SPELL+TYPE_TRAP) and chkc:IsLocation(LOCATION_ONFIELD) end if chk==0 then return Duel.IsExistingTarget(Card.IsType,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil,TYPE_SPELL+TYPE_TRAP) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,Card.IsType,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil,TYPE_SPELL+TYPE_TRAP) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,#g,0,0) end function ref.desop(e,tp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end --Recover function ref.thfilter(c) return Monkastery.Is(c) and c:IsAbleToHand() end function ref.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and ref.thfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(ref.thfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,ref.thfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,tp,LOCATION_GRAVE) end function ref.thop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) end end