name: Pendulum
card_text: Destroy as many cards in the Pendulum Zones as possible, then you can destroy 1 Spell/Trap your opponent controls.
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:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter2(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_PZONE, LOCATION_PZONE) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_PZONE, LOCATION_PZONE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_PZONE, LOCATION_PZONE)
  	if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
  		local dg = Duel.GetMatchingGroup(s.filter2, tp, 0, LOCATION_ONFIELD, nil)
  		if dg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local sg = dg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(sg)
  			Duel.Destroy(sg, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Pendulum
  Destroy as many cards in the Pendulum Zones as possible, then you can destroy 1 Spell/Trap your opponent controls.
target_text: -- Pendulum
  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:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter2(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_PZONE, LOCATION_PZONE) > 0
  	end
  	local g = Duel.GetFieldGroup(tp, LOCATION_PZONE, LOCATION_PZONE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, LOCATION_PZONE, LOCATION_PZONE)
  	if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
  		local dg = Duel.GetMatchingGroup(s.filter2, tp, 0, LOCATION_ONFIELD, nil)
  		if dg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local sg = dg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(sg)
  			Duel.Destroy(sg, REASON_EFFECT)
  		end
  	end
  end
  
  