name: Card
card_text: Look at up to 5 cards from the top of your Deck, then place them on the top of the Deck in any order. You can Tribute Summon 1 monster in addition to your Normal Summon/Set this turn. (You can only gain this effect once per turn.)
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = math.min(5, Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0))
  	if ct > 0 then
  		local t = {}
  		for i = 1, ct do
  			t[i] = i
  		end
  		local ac = 1
  		if ct > 1 then
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			ac = Duel.AnnounceNumber(tp, table.unpack(t))
  		end
  		Duel.SortDecktop(tp, tp, ac)
  	end
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetTargetRange(LOCATION_HAND, 0)
  	e1:SetCode(EFFECT_EXTRA_SUMMON_COUNT)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsLevelAbove, 5))
  	e1:SetValue(0x1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_EXTRA_SET_COUNT)
  	Duel.RegisterEffect(e2, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  
  
source_text: Card
  Look at up to 5 cards from the top of your Deck, then place them on the top of the Deck in any order. You can Tribute Summon 1 monster in addition to your Normal Summon/Set this turn. (You can only gain this effect once per turn.)
target_text: -- Card
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = math.min(5, Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0))
  	if ct > 0 then
  		local t = {}
  		for i = 1, ct do
  			t[i] = i
  		end
  		local ac = 1
  		if ct > 1 then
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			ac = Duel.AnnounceNumber(tp, table.unpack(t))
  		end
  		Duel.SortDecktop(tp, tp, ac)
  	end
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetTargetRange(LOCATION_HAND, 0)
  	e1:SetCode(EFFECT_EXTRA_SUMMON_COUNT)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsLevelAbove, 5))
  	e1:SetValue(0x1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_EXTRA_SET_COUNT)
  	Duel.RegisterEffect(e2, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  
  