--created & coded by Lyris --半物質のシード local s,id,o=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,id) e1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e1:SetCost(aux.bfgcost) e1:SetTarget(s.tdtg) e1:SetOperation(s.tdop) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_REMOVE) e2:SetCountLimit(1,id*10) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCategory(CATEGORY_POSITION) e2:SetTarget(s.postg) e2:SetOperation(s.posop) c:RegisterEffect(e2) end function s.cfilter(c) return c:IsFaceupEx() and c:IsSetCard(0xf87) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck() and not c:IsCode(id) end function s.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) and Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_GRAVE+LOCATION_REMOVED) end function s.tdop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,3,nil) if Duel.SendtoDeck(g,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)<1 then return end if g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(tp) end Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end function s.postg(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetMatchingGroup(Card.IsCanTurnSet,tp,0,LOCATION_MZONE,nil) if chk==0 then return #g>0 end Duel.SetOperationInfo(0,CATEGORY_POSITION,g,#g,0,0) end function s.filter(c) return c:IsFaceup() and c:IsType(TYPE_SPATIAL) and getmetatable(c).spt_other_space end function s.posop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsCanTurnSet,tp,0,LOCATION_MZONE,nil) local ct=Duel.ChangePosition(g,POS_FACEDOWN_DEFENSE) local sg=Duel.GetMatchingGroup(s.filter,tp,LOCATION_MZONE,0,nil) if #sg>0 and Duel.SelectEffectYesNo(tp,e:GetHandler()) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local sc=sg:Select(tp,1,1,nil):GetFirst() if ct>0 then Duel.BreakEffect() end sc:SwitchSpace() end end