name: Dante,
card_text: 2 Level 3 monsters
  Once per turn: You can detach 1 material from this card and choose a number from 1 to 3, then send that many cards from the top of your Deck to the GY; until the end of this turn, this card gains 500 ATK for each card sent to the GY this way. If this card attacks, it is changed to Defense Position at the end of the Battle Phase. If this card is sent to the GY: You can target 1 "Burning Abyss" card in your GY, except this card; add it to your hand.
external_ids: local SETCARD_ID_0 = 0xb1 --Burning
  
lua: local SETCARD_ID_0 = 0xb1 --Burning
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--to defense
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeckAsCost(tp, 1) and e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  	local ct = {}
  	for i = 3, 1, -1 do
  		if Duel.IsPlayerCanDiscardDeckAsCost(tp, i) then
  			table.insert(ct, i)
  		end
  	end
  	if #ct == 1 then
  		Duel.DiscardDeck(tp, ct[1], REASON_COST)
  		e:SetLabel(1)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local ac = Duel.AnnounceNumber(tp, table.unpack(ct))
  		Duel.DiscardDeck(tp, ac, REASON_COST)
  		e:SetLabel(ac)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local ct = e:GetLabel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct * 500)
  		c:RegisterEffect(e1)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Dante,
  2 Level 3 monsters
  Once per turn: You can detach 1 material from this card and choose a number from 1 to 3, then send that many cards from the top of your Deck to the GY; until the end of this turn, this card gains 500 ATK for each card sent to the GY this way. If this card attacks, it is changed to Defense Position at the end of the Battle Phase. If this card is sent to the GY: You can target 1 "Burning Abyss" card in your GY, except this card; add it to your hand.
target_text: -- Dante,
  local SETCARD_ID_0 = 0xb1 --Burning
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.atkcost)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--to defense
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeckAsCost(tp, 1) and e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  	local ct = {}
  	for i = 3, 1, -1 do
  		if Duel.IsPlayerCanDiscardDeckAsCost(tp, i) then
  			table.insert(ct, i)
  		end
  	end
  	if #ct == 1 then
  		Duel.DiscardDeck(tp, ct[1], REASON_COST)
  		e:SetLabel(1)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local ac = Duel.AnnounceNumber(tp, table.unpack(ct))
  		Duel.DiscardDeck(tp, ac, REASON_COST)
  		e:SetLabel(ac)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local ct = e:GetLabel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct * 500)
  		c:RegisterEffect(e1)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  