name: Draconnection
card_text: Reveal 1 Dragon-Type monster in your hand, add 1 Dragon-Type monster with the same Level from your Deck to your hand, then shuffle the revealed monster into the Deck.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter1(c, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsAbleToDeck() and not c:IsPublic() and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_DECK, 0, 1, nil, c:GetLevel())
  end
  function s.filter2(c, lv)
  	return c:IsRace(RACE_DRAGON) and c:IsLevel(lv) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND, 0, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g1 = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_HAND, 0, 1, 1, nil, tp)
  	Duel.ConfirmCards(1 - tp, g1)
  	if g1:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g2 = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_DECK, 0, 1, 1, nil, g1:GetFirst():GetLevel())
  	if g2:GetCount() == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	if Duel.SendtoHand(g2, nil, REASON_EFFECT) == 0 then
  		return
  	end
  	Duel.ConfirmCards(1 - tp, g2)
  	Duel.BreakEffect()
  	Duel.SendtoDeck(g1, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  end
  
  
source_text: Draconnection
  Reveal 1 Dragon-Type monster in your hand, add 1 Dragon-Type monster with the same Level from your Deck to your hand, then shuffle the revealed monster into the Deck.
target_text: -- Draconnection
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter1(c, tp)
  	return c:IsRace(RACE_DRAGON) and c:IsAbleToDeck() and not c:IsPublic() and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_DECK, 0, 1, nil, c:GetLevel())
  end
  function s.filter2(c, lv)
  	return c:IsRace(RACE_DRAGON) and c:IsLevel(lv) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND, 0, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g1 = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_HAND, 0, 1, 1, nil, tp)
  	Duel.ConfirmCards(1 - tp, g1)
  	if g1:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g2 = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_DECK, 0, 1, 1, nil, g1:GetFirst():GetLevel())
  	if g2:GetCount() == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	if Duel.SendtoHand(g2, nil, REASON_EFFECT) == 0 then
  		return
  	end
  	Duel.ConfirmCards(1 - tp, g2)
  	Duel.BreakEffect()
  	Duel.SendtoDeck(g1, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  end
  
  