name: Mirror
card_text: Must be Special Summoned with "The Fang of Critias", using "Mirror Force". When a monster(s) you control is targeted for an attack or by an opponent's card effect (except during the Damage Step): You can destroy all cards your opponent controls.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_BE_BATTLE_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.descon1)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_BECOME_TARGET)
  	e3:SetCondition(s.descon2)
  	c:RegisterEffect(e3)
  end
  s.material_trap = 44095762
  function s.tgfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
  end
  function s.descon1(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.tgfilter, 1, nil, tp)
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and eg:IsExists(s.tgfilter, 1, nil, tp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil) and not e:GetHandler():IsStatus(STATUS_CHAINING)
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  
source_text: Mirror
  Must be Special Summoned with "The Fang of Critias", using "Mirror Force". When a monster(s) you control is targeted for an attack or by an opponent's card effect (except during the Damage Step): You can destroy all cards your opponent controls.
target_text: -- Mirror
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_BE_BATTLE_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.descon1)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_BECOME_TARGET)
  	e3:SetCondition(s.descon2)
  	c:RegisterEffect(e3)
  end
  s.material_trap = 44095762
  function s.tgfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
  end
  function s.descon1(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.tgfilter, 1, nil, tp)
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and eg:IsExists(s.tgfilter, 1, nil, tp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil) and not e:GetHandler():IsStatus(STATUS_CHAINING)
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  