name: Cupid
card_text: You can choose a number from 1 to 3, then send that many cards from the top of your Deck to the GY; increase this card's Level by the number of cards sent to the GY this way, until the end of this turn. If this card you control is destroyed by an opponent's card and sent to your GY: You gain 1500 LP. You can only use each effect of "Cupid Volley" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.lvcost)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_RECOVER)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.reccon)
  	e2:SetTarget(s.rectg)
  	e2:SetOperation(s.recop)
  	c:RegisterEffect(e2)
  end
  function s.lvcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeckAsCost(tp, 1)
  	end
  	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.lvop(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_LEVEL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct)
  		c:RegisterEffect(e1)
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return rp == 1 - tp and c:IsPreviousControler(tp) and bit.band(r, REASON_DESTROY) ~= 0 and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1500)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, 1500)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  
  
source_text: Cupid
  You can choose a number from 1 to 3, then send that many cards from the top of your Deck to the GY; increase this card's Level by the number of cards sent to the GY this way, until the end of this turn. If this card you control is destroyed by an opponent's card and sent to your GY: You gain 1500 LP. You can only use each effect of "Cupid Volley" once per turn.
target_text: -- Cupid
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.lvcost)
  	e1:SetOperation(s.lvop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_RECOVER)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.reccon)
  	e2:SetTarget(s.rectg)
  	e2:SetOperation(s.recop)
  	c:RegisterEffect(e2)
  end
  function s.lvcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeckAsCost(tp, 1)
  	end
  	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.lvop(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_LEVEL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		e1:SetValue(ct)
  		c:RegisterEffect(e1)
  	end
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return rp == 1 - tp and c:IsPreviousControler(tp) and bit.band(r, REASON_DESTROY) ~= 0 and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1500)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, 1500)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  
  