name: Level
card_text: Send 1 face-up "LV" monster you control to the GY; Special Summon 1 monster from your hand or Deck that is listed in the sent monster's text, ignoring its Summoning conditions.
external_ids: local SETCARD_ID_0 = 0x41 --LV
  
lua: local SETCARD_ID_0 = 0x41 --LV
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, e, tp)
  	if not c:IsSetCard(SETCARD_ID_0) or not c:IsAbleToGraveAsCost() or c:IsFacedown() then
  		return false
  	end
  	local code = c:GetOriginalCode()
  	local class = _G["c" .. code]
  	if class == nil or class.lvup == nil then
  		return false
  	end
  	return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, class, e, tp)
  end
  function s.spfilter(c, class, e, tp)
  	local code = c:GetCode()
  	return c:IsCode(table.unpack(class.lvup)) and c:IsCanBeSpecialSummoned(e, 0, tp, true, true)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  	e:SetLabel(g:GetFirst():GetOriginalCode())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > -1
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local code = e:GetLabel()
  	local class = _G["c" .. code]
  	if class == nil or class.lvup == nil then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, class, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, true, true, POS_FACEUP)
  		if tc:IsPreviousLocation(LOCATION_DECK) then
  			Duel.ShuffleDeck(tp)
  		end
  	end
  end
  
  
source_text: Level
  Send 1 face-up "LV" monster you control to the GY; Special Summon 1 monster from your hand or Deck that is listed in the sent monster's text, ignoring its Summoning conditions.
target_text: -- Level
  local SETCARD_ID_0 = 0x41 --LV
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, e, tp)
  	if not c:IsSetCard(SETCARD_ID_0) or not c:IsAbleToGraveAsCost() or c:IsFacedown() then
  		return false
  	end
  	local code = c:GetOriginalCode()
  	local class = _G["c" .. code]
  	if class == nil or class.lvup == nil then
  		return false
  	end
  	return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil, class, e, tp)
  end
  function s.spfilter(c, class, e, tp)
  	local code = c:GetCode()
  	return c:IsCode(table.unpack(class.lvup)) and c:IsCanBeSpecialSummoned(e, 0, tp, true, true)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  	e:SetLabel(g:GetFirst():GetOriginalCode())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > -1
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local code = e:GetLabel()
  	local class = _G["c" .. code]
  	if class == nil or class.lvup == nil then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, class, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, true, true, POS_FACEUP)
  		if tc:IsPreviousLocation(LOCATION_DECK) then
  			Duel.ShuffleDeck(tp)
  		end
  	end
  end
  
  