name: Magic
card_text: Once per turn, you can select 1 face-up monster you control. Its ATK is halved until the End Phase, and it can attack your opponent directly this turn. During the turn you activate this effect, only the selected monster can attack.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1
  end
  function s.filter(c)
  	return c:IsFaceup()
  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(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_OATH)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.ftarget)
  	e1:SetLabel(g:GetFirst():GetFieldID())
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.ftarget(e, c)
  	return e:GetLabel() ~= c:GetFieldID()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(math.ceil(tc:GetAttack() / 2))
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DIRECT_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e2)
  	end
  end
  
  
source_text: Magic
  Once per turn, you can select 1 face-up monster you control. Its ATK is halved until the End Phase, and it can attack your opponent directly this turn. During the turn you activate this effect, only the selected monster can attack.
target_text: -- Magic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1
  end
  function s.filter(c)
  	return c:IsFaceup()
  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(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_OATH)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.ftarget)
  	e1:SetLabel(g:GetFirst():GetFieldID())
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.ftarget(e, c)
  	return e:GetLabel() ~= c:GetFieldID()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(math.ceil(tc:GetAttack() / 2))
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DIRECT_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e2)
  	end
  end
  
  