--Pandemoniumgraph Valkyrie local cid,id=GetID() function cid.initial_effect(c) aux.AddOrigPandemoniumType(c) --Search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_SZONE) e1:SetCountLimit(1) e1:SetCondition(cid.thcon) e1:SetTarget(cid.thtg) e1:SetOperation(cid.thop) c:RegisterEffect(e1) aux.EnablePandemoniumAttribute(c,e1) --Activate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e2:SetCode(EVENT_DESTROYED) e2:SetTarget(cid.tg) e2:SetOperation(cid.op) c:RegisterEffect(e2) end function cid.thfilter(c) return c:IsSetCard(0xcf80) and c:IsAbleToHand() and not c:IsCode(id) end function cid.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cid.op(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function cid.cfilter(c) return c:IsAbleToHand() and c:IsSetCard(0xcf80) and not c:IsCode(id) end function cid.thcon(e,tp,eg,ep,ev,re,r,rp) return aux.PandActCheck(e) and Duel.GetTurnPlayer()==tp and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)<3 then return false end local g=Duel.GetDecktopGroup(tp,3) local result=g:FilterCount(Card.IsAbleToHand,nil)>0 return result end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK) end function cid.thop(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) Duel.ConfirmDecktop(p,3) local g=Duel.GetDecktopGroup(p,3) if g:GetCount()>0 then if g:IsExists(cid.cfilter,1,nil) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,cid.cfilter,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) end Duel.ShuffleDeck(tp) Duel.BreakEffect() Duel.Destroy(e:GetHandler(),REASON_EFFECT) end end