name: Infernity
card_text: During your Draw Phase, if you have no cards in your hand, instead of conducting your normal draw: You can banish this card from your GY, then activate 1 of these effects;
  ● Place 1 "Infernity" card from your Deck on top of your Deck.
  ● Set 1 "Void" Spell/Trap directly from your Deck.
external_ids: local SETCARD_ID_0 = 0xb --Infernity
  local SETCARD_ID_1 = 0xc5 --Void
  
lua: local SETCARD_ID_0 = 0xb --Infernity
  local SETCARD_ID_1 = 0xc5 --Void
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Optional
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_GRAVE)
  	e1:SetCode(EVENT_PREDRAW)
  	e1:SetCondition(s.opcon)
  	e1:SetCost(aux.bfgcost)
  	e1:SetTarget(s.optg)
  	e1:SetOperation(s.opop)
  	c:RegisterEffect(e1)
  end
  function s.opcon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0
  end
  function s.ttopfilter(c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  function s.ssetfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.optg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local b1 = Duel.IsExistingMatchingCard(s.ttopfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	local b2 = Duel.IsExistingMatchingCard(s.ssetfilter, tp, LOCATION_DECK, 0, 1, nil)
  	if chk == 0 then
  		return aux.IsPlayerCanNormalDraw(tp) and (b1 or b2)
  	end
  	aux.GiveUpNormalDraw(e, tp)
  	local off = 1
  	local ops, opval = {}, {}
  	if b1 then
  		ops[off] = aux.Stringid(id, 1)
  		opval[off] = 0
  		off = off + 1
  	end
  	if b2 then
  		ops[off] = aux.Stringid(id, 2)
  		opval[off] = 1
  		off = off + 1
  	end
  	local op = Duel.SelectOption(tp, table.unpack(ops)) + 1
  	local sel = opval[op]
  	e:SetLabel(sel)
  end
  function s.opop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local sel = e:GetLabel()
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  		local g = Duel.SelectMatchingCard(tp, s.ttopfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc then
  			Duel.ShuffleDeck(tp)
  			Duel.MoveSequence(tc, SEQ_DECKTOP)
  			Duel.ConfirmDecktop(tp, 1)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.ssetfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  
  
source_text: Infernity
  During your Draw Phase, if you have no cards in your hand, instead of conducting your normal draw: You can banish this card from your GY, then activate 1 of these effects;
  ● Place 1 "Infernity" card from your Deck on top of your Deck.
  ● Set 1 "Void" Spell/Trap directly from your Deck.
target_text: -- Infernity
  local SETCARD_ID_0 = 0xb --Infernity
  local SETCARD_ID_1 = 0xc5 --Void
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Optional
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_GRAVE)
  	e1:SetCode(EVENT_PREDRAW)
  	e1:SetCondition(s.opcon)
  	e1:SetCost(aux.bfgcost)
  	e1:SetTarget(s.optg)
  	e1:SetOperation(s.opop)
  	c:RegisterEffect(e1)
  end
  function s.opcon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0
  end
  function s.ttopfilter(c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  function s.ssetfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.optg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local b1 = Duel.IsExistingMatchingCard(s.ttopfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	local b2 = Duel.IsExistingMatchingCard(s.ssetfilter, tp, LOCATION_DECK, 0, 1, nil)
  	if chk == 0 then
  		return aux.IsPlayerCanNormalDraw(tp) and (b1 or b2)
  	end
  	aux.GiveUpNormalDraw(e, tp)
  	local off = 1
  	local ops, opval = {}, {}
  	if b1 then
  		ops[off] = aux.Stringid(id, 1)
  		opval[off] = 0
  		off = off + 1
  	end
  	if b2 then
  		ops[off] = aux.Stringid(id, 2)
  		opval[off] = 1
  		off = off + 1
  	end
  	local op = Duel.SelectOption(tp, table.unpack(ops)) + 1
  	local sel = opval[op]
  	e:SetLabel(sel)
  end
  function s.opop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local sel = e:GetLabel()
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  		local g = Duel.SelectMatchingCard(tp, s.ttopfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc then
  			Duel.ShuffleDeck(tp)
  			Duel.MoveSequence(tc, SEQ_DECKTOP)
  			Duel.ConfirmDecktop(tp, 1)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.ssetfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g:GetFirst())
  		end
  	end
  end
  
  