name: Slash
card_text: Discard 1 card; send cards from the top of your Deck to the GY, equal to the number of cards your opponent controls, then draw 1 card and show it. Then, if it was "Slash Draw", send it to the GY, and if you do, destroy as many cards on the field as possible, then inflict 2000 damage to your opponent for each card destroyed and sent to the GY by this effect. If the card you drew was not "Slash Draw", shuffle cards from your GY into your Deck, equal to the number of cards sent from your Deck to the GY by this effect. You can only activate 1 "Slash Draw" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DECKDES + CATEGORY_DRAW + CATEGORY_DESTROY + CATEGORY_DAMAGE + CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	if chk == 0 then
  		return ct > 0 and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > ct and Duel.IsPlayerCanDiscardDeck(tp, ct) and Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	if ct > 0 and Duel.DiscardDeck(tp, ct, REASON_EFFECT) ~= 0 then
  		local ct2 = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE):GetCount()
  		if ct2 == 0 then
  			return
  		end
  		Duel.BreakEffect()
  		if Duel.Draw(tp, 1, REASON_EFFECT) ~= 0 then
  			local tc = Duel.GetOperatedGroup():GetFirst()
  			Duel.ConfirmCards(1 - tp, tc)
  			Duel.ShuffleHand(tp)
  			if tc:IsCode(id) then
  				if Duel.SendtoGrave(tc, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_GRAVE) then
  					local sg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, aux.ExceptThisCard(e))
  					Duel.Destroy(sg, REASON_EFFECT)
  					local tg = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  					if tg:GetCount() > 0 then
  						local dam = tg:GetCount() * 2000
  						if dam > 0 then
  							Duel.BreakEffect()
  							Duel.Damage(1 - tp, dam, REASON_EFFECT)
  						end
  					end
  				end
  			else
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  				local dg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(Card.IsAbleToDeck), tp, LOCATION_GRAVE, 0, ct2, ct2, nil)
  				if dg:GetCount() > 0 then
  					Duel.HintSelection(dg)
  					Duel.SendtoDeck(dg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  				end
  			end
  		end
  	end
  end
  
  
source_text: Slash
  Discard 1 card; send cards from the top of your Deck to the GY, equal to the number of cards your opponent controls, then draw 1 card and show it. Then, if it was "Slash Draw", send it to the GY, and if you do, destroy as many cards on the field as possible, then inflict 2000 damage to your opponent for each card destroyed and sent to the GY by this effect. If the card you drew was not "Slash Draw", shuffle cards from your GY into your Deck, equal to the number of cards sent from your Deck to the GY by this effect. You can only activate 1 "Slash Draw" per turn.
target_text: -- Slash
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DECKDES + CATEGORY_DRAW + CATEGORY_DESTROY + CATEGORY_DAMAGE + CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	if chk == 0 then
  		return ct > 0 and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > ct and Duel.IsPlayerCanDiscardDeck(tp, ct) and Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, nil, 0, tp, ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_ONFIELD)
  	if ct > 0 and Duel.DiscardDeck(tp, ct, REASON_EFFECT) ~= 0 then
  		local ct2 = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE):GetCount()
  		if ct2 == 0 then
  			return
  		end
  		Duel.BreakEffect()
  		if Duel.Draw(tp, 1, REASON_EFFECT) ~= 0 then
  			local tc = Duel.GetOperatedGroup():GetFirst()
  			Duel.ConfirmCards(1 - tp, tc)
  			Duel.ShuffleHand(tp)
  			if tc:IsCode(id) then
  				if Duel.SendtoGrave(tc, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_GRAVE) then
  					local sg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, aux.ExceptThisCard(e))
  					Duel.Destroy(sg, REASON_EFFECT)
  					local tg = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  					if tg:GetCount() > 0 then
  						local dam = tg:GetCount() * 2000
  						if dam > 0 then
  							Duel.BreakEffect()
  							Duel.Damage(1 - tp, dam, REASON_EFFECT)
  						end
  					end
  				end
  			else
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  				local dg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(Card.IsAbleToDeck), tp, LOCATION_GRAVE, 0, ct2, ct2, nil)
  				if dg:GetCount() > 0 then
  					Duel.HintSelection(dg)
  					Duel.SendtoDeck(dg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  				end
  			end
  		end
  	end
  end
  
  