name: Gladiator
card_text: If a face-up "Gladiator Beast" monster is on the field, activate 1 of these effects:
  ● Select 1 face-up monster your opponent controls, and change its battle position.
  ● Select 1 face-up "Gladiator Beast" monster your opponent controls, and take control of it until the End Phase.
external_ids: local SETCARD_ID_0 = 0x1019 --Gladiator
  
lua: local SETCARD_ID_0 = 0x1019 --Gladiator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.filter(c, e)
  	return c:IsFaceup() and c:IsCanBeEffectTarget(e) and c:IsCanChangePosition()
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToChangeControler()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, 0, LOCATION_MZONE, nil, e)
  	local cg = Duel.GetMatchingGroup(s.filter2, tp, 0, LOCATION_MZONE, nil)
  	local sel = 0
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EFFECT)
  	if cg:GetCount() == 0 then
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	end
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 1, 0, 0)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  		local sg = cg:Select(tp, 1, 1, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  	end
  	e:SetLabel(sel)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		if e:GetLabel() == 0 then
  			Duel.ChangePosition(tc, POS_FACEUP_DEFENSE, 0, POS_FACEUP_ATTACK, 0)
  		else
  			Duel.GetControl(tc, tp, PHASE_END, 1)
  		end
  	end
  end
  
  
source_text: Gladiator
  If a face-up "Gladiator Beast" monster is on the field, activate 1 of these effects:
  ● Select 1 face-up monster your opponent controls, and change its battle position.
  ● Select 1 face-up "Gladiator Beast" monster your opponent controls, and take control of it until the End Phase.
target_text: -- Gladiator
  local SETCARD_ID_0 = 0x1019 --Gladiator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.filter(c, e)
  	return c:IsFaceup() and c:IsCanBeEffectTarget(e) and c:IsCanChangePosition()
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToChangeControler()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, 0, LOCATION_MZONE, nil, e)
  	local cg = Duel.GetMatchingGroup(s.filter2, tp, 0, LOCATION_MZONE, nil)
  	local sel = 0
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EFFECT)
  	if cg:GetCount() == 0 then
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	end
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 1, 0, 0)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  		local sg = cg:Select(tp, 1, 1, nil)
  		Duel.SetTargetCard(sg)
  		Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  	end
  	e:SetLabel(sel)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		if e:GetLabel() == 0 then
  			Duel.ChangePosition(tc, POS_FACEUP_DEFENSE, 0, POS_FACEUP_ATTACK, 0)
  		else
  			Duel.GetControl(tc, tp, PHASE_END, 1)
  		end
  	end
  end
  
  