name: スウィッチヒーロー
card_text: 1:お互いのフィールドのモンスターの数が同じ場合、そのモンスターのコントロールを全て入れ替える。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return not c:IsAbleToChangeControler()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	local g1 = g:Filter(Card.IsControler, nil, tp)
  	local g2 = g:Filter(Card.IsControler, nil, 1 - tp)
  	if chk == 0 then
  		return g1:GetCount() > 0
  			and g1:GetCount() == g2:GetCount()
  			and g:FilterCount(s.filter, nil) == 0
  			and Duel.GetMZoneCount(tp, g1, tp, LOCATION_REASON_CONTROL) >= g2:GetCount()
  			and Duel.GetMZoneCount(1 - tp, g2, 1 - tp, LOCATION_REASON_CONTROL) >= g1:GetCount()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local g2 = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	Duel.SwapControl(g1, g2)
  end
  
  
source_text: スウィッチヒーロー
  1:お互いのフィールドのモンスターの数が同じ場合、そのモンスターのコントロールを全て入れ替える。
target_text: -- スウィッチヒーロー
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return not c:IsAbleToChangeControler()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, LOCATION_MZONE)
  	local g1 = g:Filter(Card.IsControler, nil, tp)
  	local g2 = g:Filter(Card.IsControler, nil, 1 - tp)
  	if chk == 0 then
  		return g1:GetCount() > 0
  			and g1:GetCount() == g2:GetCount()
  			and g:FilterCount(s.filter, nil) == 0
  			and Duel.GetMZoneCount(tp, g1, tp, LOCATION_REASON_CONTROL) >= g2:GetCount()
  			and Duel.GetMZoneCount(1 - tp, g2, 1 - tp, LOCATION_REASON_CONTROL) >= g1:GetCount()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local g2 = Duel.GetFieldGroup(tp, 0, LOCATION_MZONE)
  	Duel.SwapControl(g1, g2)
  end
  
  