name: Link
card_text: If you control a Link-4 or higher monster: Destroy monsters your opponent controls, up to the number of Link-3 or higher monsters you control. You can only activate 1 "Link Hole" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsLinkAbove(4)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLinkAbove(3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_MZONE, 0, nil)
  	local dg = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	if chk == 0 then
  		return ct > 0 and dg:GetCount() > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, nil, tp, 0, LOCATION_MZONE, 1, ct, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  
source_text: Link
  If you control a Link-4 or higher monster: Destroy monsters your opponent controls, up to the number of Link-3 or higher monsters you control. You can only activate 1 "Link Hole" per turn.
target_text: -- Link
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsLinkAbove(4)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLinkAbove(3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_MZONE, 0, nil)
  	local dg = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	if chk == 0 then
  		return ct > 0 and dg:GetCount() > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if ct == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, nil, tp, 0, LOCATION_MZONE, 1, ct, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  