name: Topologic
card_text: 2+ Effect Monsters
  If a monster(s) is Special Summoned to a zone(s) this card points to: Banish as many of those monster(s) as possible, also as many Spells/Traps on the field as possible, and if you do, inflict 500 damage to your opponent for each of their cards banished by this effect.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 2)
  	--banish
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.rmcon)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, ec)
  	if c:IsLocation(LOCATION_MZONE) then
  		return ec:GetLinkedGroup():IsContains(c)
  	else
  		return bit.extract(ec:GetLinkedZone(c:GetPreviousControler()), c:GetPreviousSequence()) ~= 0
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, e:GetHandler())
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = eg:Filter(s.cfilter, nil, e:GetHandler())
  	local tg = g:Filter(Card.IsLocation, nil, LOCATION_MZONE)
  	Duel.SetTargetCard(tg)
  	local g2 = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, TYPE_SPELL + TYPE_TRAP)
  	g:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, g:GetCount(), 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	local g2 = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, TYPE_SPELL + TYPE_TRAP)
  	g:Merge(g2)
  	if Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local ct = Duel.GetOperatedGroup():FilterCount(Card.IsControler, nil, 1 - tp)
  		Duel.Damage(1 - tp, ct * 500, REASON_EFFECT)
  	end
  end
  
  
source_text: Topologic
  2+ Effect Monsters
  If a monster(s) is Special Summoned to a zone(s) this card points to: Banish as many of those monster(s) as possible, also as many Spells/Traps on the field as possible, and if you do, inflict 500 damage to your opponent for each of their cards banished by this effect.
target_text: -- Topologic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 2)
  	--banish
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.rmcon)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, ec)
  	if c:IsLocation(LOCATION_MZONE) then
  		return ec:GetLinkedGroup():IsContains(c)
  	else
  		return bit.extract(ec:GetLinkedZone(c:GetPreviousControler()), c:GetPreviousSequence()) ~= 0
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, e:GetHandler())
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = eg:Filter(s.cfilter, nil, e:GetHandler())
  	local tg = g:Filter(Card.IsLocation, nil, LOCATION_MZONE)
  	Duel.SetTargetCard(tg)
  	local g2 = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, TYPE_SPELL + TYPE_TRAP)
  	g:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, g:GetCount(), 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	local g2 = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil, TYPE_SPELL + TYPE_TRAP)
  	g:Merge(g2)
  	if Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local ct = Duel.GetOperatedGroup():FilterCount(Card.IsControler, nil, 1 - tp)
  		Duel.Damage(1 - tp, ct * 500, REASON_EFFECT)
  	end
  end
  
  