name: Gemini
card_text: Activate only when a Gemini monster that is treated as an Effect Monster is destroyed by battle. Destroy all monsters 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_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLED)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  s.has_text_type = TYPE_DUAL
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local t = Duel.GetAttackTarget()
  	if a and a:IsDualState() and a:IsStatus(STATUS_BATTLE_DESTROYED) then
  		a:RegisterFlagEffect(id, RESET_PHASE + PHASE_DAMAGE, 0, 1)
  	end
  	if t and t:IsDualState() and t:IsStatus(STATUS_BATTLE_DESTROYED) then
  		t:RegisterFlagEffect(id, RESET_PHASE + PHASE_DAMAGE, 0, 1)
  	end
  end
  function s.filter(c)
  	return c:GetFlagEffect(id) ~= 0
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.filter, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, sg, sg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(sg, REASON_EFFECT)
  end
  
  
source_text: Gemini
  Activate only when a Gemini monster that is treated as an Effect Monster is destroyed by battle. Destroy all monsters your opponent controls.
target_text: -- Gemini
  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_BATTLE_DESTROYED)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLED)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  s.has_text_type = TYPE_DUAL
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local t = Duel.GetAttackTarget()
  	if a and a:IsDualState() and a:IsStatus(STATUS_BATTLE_DESTROYED) then
  		a:RegisterFlagEffect(id, RESET_PHASE + PHASE_DAMAGE, 0, 1)
  	end
  	if t and t:IsDualState() and t:IsStatus(STATUS_BATTLE_DESTROYED) then
  		t:RegisterFlagEffect(id, RESET_PHASE + PHASE_DAMAGE, 0, 1)
  	end
  end
  function s.filter(c)
  	return c:GetFlagEffect(id) ~= 0
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.filter, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, sg, sg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  	Duel.Destroy(sg, REASON_EFFECT)
  end
  
  