--Alchemage Experiment local cid,id=GetID() function cid.initial_effect(c) --Excavate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_DECKDES) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id) e1:SetTarget(cid.target) e1:SetOperation(cid.operation) c:RegisterEffect(e1) --Recover local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_TODECK) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetRange(LOCATION_GRAVE) e4:SetCost(aux.bfgcost) e4:SetCountLimit(1,id+100) e4:SetTarget(cid.drtg) e4:SetOperation(cid.drop) c:RegisterEffect(e4) end --Filters function cid.filter(c) return c:IsAbleToHand() and c:IsSetCard(0x8108) end function cid.tdfilter(c) return c:IsSetCard(0x8108) and c:IsAbleToDeck() end --Excavate function cid.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDiscardDeck(tp,3) and Duel.GetDecktopGroup(tp,3):FilterCount(Card.IsAbleToHand,nil)>0 end end function cid.operation(e,tp,eg,ep,ev,re,r,rp) if not Duel.IsPlayerCanDiscardDeck(tp,3) then return end Duel.ConfirmDecktop(tp,3) local g=Duel.GetDecktopGroup(tp,3) if g:GetCount()>0 then Duel.DisableShuffleCheck() if g:IsExists(cid.filter,1,nil) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,cid.filter,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) g:Sub(sg) Duel.SendtoGrave(g,REASON_EFFECT+REASON_REVEAL) else Duel.ShuffleDeck(tp) end end end --Recycle function cid.drtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(cid.tdfilter,tp,LOCATION_GRAVE,0,3,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,cid.tdfilter,tp,LOCATION_GRAVE,0,3,3,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,3,0,0) end function cid.drop(e,tp,eg,ep,ev,re,r,rp) local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if tg:GetCount()<=0 then return end Duel.SendtoDeck(tg,nil,2,REASON_EFFECT) local g=Duel.GetOperatedGroup() local ct=g:GetCount() if Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_ONFIELD,0,1,e:GetHandler()) then local cc=Duel.SelectMatchingCard(tp,Card.IsFaceup,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler()) cc:GetFirst():AddCounter(0x1818,ct) end end