name: March
card_text: Target 1 "Lightsworn" monster in your GY that has a Level; add it to your hand, then banish a number of cards from the top of your Deck equal to the original Level of that monster in your hand. You can only activate 1 "March of the Dark Brigade" per turn.
external_ids: local SETCARD_ID_0 = 0x38 --Lightsworn
  
lua: local SETCARD_ID_0 = 0x38 --Lightsworn
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	if not c:IsType(TYPE_MONSTER) or not c:IsSetCard(SETCARD_ID_0) or c:GetOriginalLevel() <= 0 or not c:IsAbleToHand() then
  		return false
  	end
  	local g = Duel.GetDecktopGroup(tp, c:GetOriginalLevel())
  	return g:FilterCount(Card.IsAbleToRemove, nil) == c:GetOriginalLevel()
  end
  function s.target(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, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, tp)
  	local rg = Duel.GetDecktopGroup(tp, g:GetFirst():GetOriginalLevel())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, rg, rg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_HAND) then
  		Duel.BreakEffect()
  		local ol = tc:GetOriginalLevel()
  		local rg = Duel.GetDecktopGroup(tp, ol)
  		Duel.DisableShuffleCheck()
  		Duel.Remove(rg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  
source_text: March
  Target 1 "Lightsworn" monster in your GY that has a Level; add it to your hand, then banish a number of cards from the top of your Deck equal to the original Level of that monster in your hand. You can only activate 1 "March of the Dark Brigade" per turn.
target_text: -- March
  local SETCARD_ID_0 = 0x38 --Lightsworn
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	if not c:IsType(TYPE_MONSTER) or not c:IsSetCard(SETCARD_ID_0) or c:GetOriginalLevel() <= 0 or not c:IsAbleToHand() then
  		return false
  	end
  	local g = Duel.GetDecktopGroup(tp, c:GetOriginalLevel())
  	return g:FilterCount(Card.IsAbleToRemove, nil) == c:GetOriginalLevel()
  end
  function s.target(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, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, tp)
  	local rg = Duel.GetDecktopGroup(tp, g:GetFirst():GetOriginalLevel())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, rg, rg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_HAND) then
  		Duel.BreakEffect()
  		local ol = tc:GetOriginalLevel()
  		local rg = Duel.GetDecktopGroup(tp, ol)
  		Duel.DisableShuffleCheck()
  		Duel.Remove(rg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  