name: Infernity
card_text: During your Main Phase: You can discard your entire hand. If this card is sent to the GY: You can send 1 "Infernity" monster from your Deck to the GY. You must have no cards in your hand to activate and to resolve this effect. You can only use each effect of "Infernity Sage" once per turn.
external_ids: local SETCARD_ID_0 = 0xb --Infernity
  
lua: local SETCARD_ID_0 = 0xb --Infernity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Discard
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_HANDES)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.hdtg)
  	e1:SetOperation(s.hdop)
  	c:RegisterEffect(e1)
  	--To GY
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_ACTIVATE_CONDITION)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, g:GetCount())
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Infernity
  During your Main Phase: You can discard your entire hand. If this card is sent to the GY: You can send 1 "Infernity" monster from your Deck to the GY. You must have no cards in your hand to activate and to resolve this effect. You can only use each effect of "Infernity Sage" once per turn.
target_text: -- Infernity
  local SETCARD_ID_0 = 0xb --Infernity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Discard
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_HANDES)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.hdtg)
  	e1:SetOperation(s.hdop)
  	c:RegisterEffect(e1)
  	--To GY
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_ACTIVATE_CONDITION)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, g:GetCount())
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  
  