name: Evenly
card_text: At the end of the Battle Phase, if your opponent controls more cards than you do: You can make your opponent banish cards from their field face-down so they control the same number of cards as you do. If you control no cards, you can activate this card from your hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_BATTLE_END)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--act in hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
  	e2:SetCondition(s.handcon)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_BATTLE
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_ONFIELD)
  	local ct = g:GetCount() - Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if e:GetHandler():IsLocation(LOCATION_HAND) then
  		ct = ct - 1
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanRemove(1 - tp) and ct > 0 and g:IsExists(Card.IsAbleToRemove, 1, nil, 1 - tp, POS_FACEDOWN, REASON_RULE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsPlayerCanRemove(1 - tp) then
  		return
  	end
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_ONFIELD)
  	local ct = g:GetCount() - Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if ct > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_REMOVE)
  		local sg = g:FilterSelect(1 - tp, Card.IsAbleToRemove, ct, ct, nil, 1 - tp, POS_FACEDOWN, REASON_RULE)
  		Duel.Remove(sg, POS_FACEDOWN, REASON_RULE, 1 - tp)
  	end
  end
  function s.handcon(e)
  	return Duel.GetFieldGroupCount(e:GetHandlerPlayer(), LOCATION_ONFIELD, 0) == 0
  end
  
  
source_text: Evenly
  At the end of the Battle Phase, if your opponent controls more cards than you do: You can make your opponent banish cards from their field face-down so they control the same number of cards as you do. If you control no cards, you can activate this card from your hand.
target_text: -- Evenly
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(TIMING_BATTLE_END)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--act in hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
  	e2:SetCondition(s.handcon)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_BATTLE
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_ONFIELD)
  	local ct = g:GetCount() - Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if e:GetHandler():IsLocation(LOCATION_HAND) then
  		ct = ct - 1
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanRemove(1 - tp) and ct > 0 and g:IsExists(Card.IsAbleToRemove, 1, nil, 1 - tp, POS_FACEDOWN, REASON_RULE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsPlayerCanRemove(1 - tp) then
  		return
  	end
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_ONFIELD)
  	local ct = g:GetCount() - Duel.GetFieldGroupCount(tp, LOCATION_ONFIELD, 0)
  	if ct > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_REMOVE)
  		local sg = g:FilterSelect(1 - tp, Card.IsAbleToRemove, ct, ct, nil, 1 - tp, POS_FACEDOWN, REASON_RULE)
  		Duel.Remove(sg, POS_FACEDOWN, REASON_RULE, 1 - tp)
  	end
  end
  function s.handcon(e)
  	return Duel.GetFieldGroupCount(e:GetHandlerPlayer(), LOCATION_ONFIELD, 0) == 0
  end
  
  