--created & coded by Lyris, art from Cardfight!! Vanguard's "Officer Cadet of the First Battle" --アーマリン・レリック・コレクター local s,id,o=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_HAND+LOCATION_MZONE) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetCondition(s.con) e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND+CATEGORY_DESTROY) e1:SetHintTiming(TIMING_DAMAGE_STEP) e1:SetTarget(s.tg) e1:SetOperation(s.op) c:RegisterEffect(e1) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e5:SetCode(EVENT_DESTROYED) e5:SetCondition(function(e,tp,eg,ep,ev,re,r) return r&REASON_EFFECT>0 end) e5:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e5:SetTarget(s.drtg) e5:SetOperation(s.drop) c:RegisterEffect(e5) end function s.con(e,tp) local a=Duel.GetAttacker() if not a then return false end if a:IsControler(1-tp) then a=Duel.GetAttackTarget() end return a~=e:GetHandler() and a:IsSetCard(0xa6c) and a:IsRelateToBattle() and Duel.GetCurrentPhase()==PHASE_DAMAGE and not Duel.IsDamageCalculated() end function s.filter(c) return c:IsSetCard(0xa6c) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and not c:IsCode(id) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.op(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil) if Duel.SendtoHand(g,nil,REASON_EFFECT)==0 then return end Duel.ConfirmCards(1-tp,g) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.BreakEffect() Duel.Destroy(c,REASON_EFFECT) end end function s.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,3,tp,LOCATION_GRAVE) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function s.tdfilter(c) return c:IsSetCard(0xa6c) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck() end function s.drop(e,tp,eg,ep,ev,re,r,rp) local mg=Duel.GetMatchingGroup(s.tdfilter,tp,LOCATION_GRAVE,0,e:GetHandler()) if #mg<3 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=mg:Select(tp,3,3,nil) Duel.HintSelection(g) Duel.SendtoDeck(g,nil,2,REASON_EFFECT) if g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(tp) end if g:FilterCount(Card.IsLocation,nil,LOCATION_DECK+LOCATION_EXTRA)==3 then Duel.Draw(tp,1,REASON_EFFECT) end end