--Rainbow Dice function c32843001.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c32843001.target) e1:SetOperation(c32843001.activate) c:RegisterEffect(e1) end function c32843001.filter(c) return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand() end function c32843001.filter1(c) return c:IsAttribute(ATTRIBUTE_DARK) and c:IsAbleToHand() end function c32843001.filter2(c) return c:IsAttribute(ATTRIBUTE_EARTH) and c:IsAbleToHand() end function c32843001.filter3(c) return c:IsAttribute(ATTRIBUTE_WIND) and c:IsAbleToHand() end function c32843001.filter4(c) return c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToHand() end function c32843001.filter5(c) return c:IsAttribute(ATTRIBUTE_FIRE) and c:IsAbleToHand() end function c32843001.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DICE,nil,0,tp,1) end function c32843001.activate(e,tp,eg,ep,ev,re,r,rp) local dc=Duel.TossDice(tp,1) if dc==1 then local g=Duel.SelectMatchingCard(tp,c32843001.filter2,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif dc==2 then local g=Duel.SelectMatchingCard(tp,c32843001.filter3,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif dc==3 then local g=Duel.SelectMatchingCard(tp,c32843001.filter4,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif dc==4 then local g=Duel.SelectMatchingCard(tp,c32843001.filter5,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif dc==5 then local g=Duel.SelectMatchingCard(tp,c32843001.filter,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end elseif dc==6 then local g=Duel.SelectMatchingCard(tp,c32843001.filter1,tp,LOCATION_DECK,0,0,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end end