name: Planet
card_text: Tribute 1 "Alien" monster; destroy all face-up monsters your opponent controls without A-Counters, also until the end of your opponent's 3rd turn after this card resolves, place 1 A-Counter on each monster they Summon.
external_ids: local COUNTER_ID_0 = 0x100e --A-Counter
  
lua: local COUNTER_ID_0 = 0x100e --A-Counter
  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:SetHintTiming(0, 0x1e1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  s.counter_add_list = { 0x100e }
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0xc)
  	end
  	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0xc)
  	Duel.Release(g, REASON_COST)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:GetCounter(COUNTER_ID_0) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.tgfilter, tp, 0, LOCATION_MZONE, nil)
  	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.GetMatchingGroup(s.tgfilter, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.ctop1)
  	e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 3)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetOperation(s.ctop2)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.ctop1(e, tp, eg, ep, ev, re, r, rp)
  	if ep ~= tp then
  		eg:GetFirst():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.ctop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsFaceup() and tc:IsSummonPlayer(1 - tp) then
  			tc:AddCounter(COUNTER_ID_0, 1)
  		end
  		tc = eg:GetNext()
  	end
  end
  
  
source_text: Planet
  Tribute 1 "Alien" monster; destroy all face-up monsters your opponent controls without A-Counters, also until the end of your opponent's 3rd turn after this card resolves, place 1 A-Counter on each monster they Summon.
target_text: -- Planet
  local COUNTER_ID_0 = 0x100e --A-Counter
  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:SetHintTiming(0, 0x1e1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  s.counter_add_list = { 0x100e }
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0xc)
  	end
  	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0xc)
  	Duel.Release(g, REASON_COST)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:GetCounter(COUNTER_ID_0) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.tgfilter, tp, 0, LOCATION_MZONE, nil)
  	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.GetMatchingGroup(s.tgfilter, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.ctop1)
  	e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 3)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetOperation(s.ctop2)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.ctop1(e, tp, eg, ep, ev, re, r, rp)
  	if ep ~= tp then
  		eg:GetFirst():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.ctop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsFaceup() and tc:IsSummonPlayer(1 - tp) then
  			tc:AddCounter(COUNTER_ID_0, 1)
  		end
  		tc = eg:GetNext()
  	end
  end
  
  