name: Number
card_text: 3 Level 5 monsters
  Once per turn, when this card is targeted for an attack: It gains ATK equal to that attacking monster's original ATK, until the End Phase. If this face-up card on the field would be destroyed, you can detach 1 Xyz Material from this card instead. When this card on the field is destroyed by a card effect while it has no Xyz Materials: You can Special Summon 1 "Number 92: Heart-eartH Dragon" from your Extra Deck and attach this card from the Graveyard to it as an Xyz Material. (This Special Summon is treated as an Xyz Summon.)
external_ids: local CARD_ID_0 = 97403510 --Number 92: Heart-eartH Dragon
  
lua: local CARD_ID_0 = 97403510 --Number 92: Heart-eartH Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.atktg)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.reptg)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  aux.xyz_number[id] = 53
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(Duel.GetAttacker())
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsAttackable() and not tc:IsStatus(STATUS_ATTACK_CANCELED) then
  		local atk = tc:GetBaseAttack()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
  		return true
  	else
  		return false
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_EFFECT) and c:GetPreviousOverlayCountOnField() == 0 and c:IsLocation(LOCATION_GRAVE)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_0) and e:GetHandler():IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return aux.MustMaterialCheck(e:GetHandler(), tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, e:GetHandler(), 1, tp, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) then
  		return
  	end
  	local tc = Duel.GetFirstMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  	if tc then
  		local cg = Group.FromCards(c)
  		tc:SetMaterial(cg)
  		Duel.Overlay(tc, cg)
  		Duel.SpecialSummon(tc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  
  
source_text: Number
  3 Level 5 monsters
  Once per turn, when this card is targeted for an attack: It gains ATK equal to that attacking monster's original ATK, until the End Phase. If this face-up card on the field would be destroyed, you can detach 1 Xyz Material from this card instead. When this card on the field is destroyed by a card effect while it has no Xyz Materials: You can Special Summon 1 "Number 92: Heart-eartH Dragon" from your Extra Deck and attach this card from the Graveyard to it as an Xyz Material. (This Special Summon is treated as an Xyz Summon.)
target_text: -- Number
  local CARD_ID_0 = 97403510 --Number 92: Heart-eartH Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.atktg)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.reptg)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  aux.xyz_number[id] = 53
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(Duel.GetAttacker())
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsAttackable() and not tc:IsStatus(STATUS_ATTACK_CANCELED) then
  		local atk = tc:GetBaseAttack()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
  		return true
  	else
  		return false
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_EFFECT) and c:GetPreviousOverlayCountOnField() == 0 and c:IsLocation(LOCATION_GRAVE)
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_0) and e:GetHandler():IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return aux.MustMaterialCheck(e:GetHandler(), tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, e:GetHandler(), 1, tp, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) then
  		return
  	end
  	local tc = Duel.GetFirstMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  	if tc then
  		local cg = Group.FromCards(c)
  		tc:SetMaterial(cg)
  		Duel.Overlay(tc, cg)
  		Duel.SpecialSummon(tc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  
  