name: Infernity
card_text: Activate only by discarding all the cards in your hand when an "Infernity" monster you control is destroyed by battle and sent to the Graveyard. Select and Special Summon that monster from your Graveyard, and inflict 1000 damage to your opponent.
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)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsLocation(LOCATION_GRAVE)
  		and c:IsPreviousControler(tp)
  		and c:IsReason(REASON_BATTLE)
  		and c:IsCanBeEffectTarget(e)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return eg:IsContains(chkc) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and eg:IsExists(s.filter, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = eg:FilterSelect(tp, s.filter, 1, 1, nil, e, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 1, 1 - tp, 1000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	Duel.Damage(1 - tp, 1000, REASON_EFFECT)
  end
  
  
source_text: Infernity
  Activate only by discarding all the cards in your hand when an "Infernity" monster you control is destroyed by battle and sent to the Graveyard. Select and Special Summon that monster from your Graveyard, and inflict 1000 damage to your opponent.
target_text: -- Infernity
  local SETCARD_ID_0 = 0xb --Infernity
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BATTLE_DESTROYED)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  		and c:IsLocation(LOCATION_GRAVE)
  		and c:IsPreviousControler(tp)
  		and c:IsReason(REASON_BATTLE)
  		and c:IsCanBeEffectTarget(e)
  		and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return eg:IsContains(chkc) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and eg:IsExists(s.filter, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = eg:FilterSelect(tp, s.filter, 1, 1, nil, e, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 1, 1 - tp, 1000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	Duel.Damage(1 - tp, 1000, REASON_EFFECT)
  end
  
  