name: Staunch
card_text: You can only activate this card when your opponent declares an attack. Select 1 face-up monster on your side of the field. During this turn, your opponent can only designate the selected monster as an attack target and your opponent must attack the selected monster with all face-up monsters.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local at = Duel.GetAttackTarget()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() and chkc ~= at
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, at)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, at)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local fid = tc:GetRealFieldID()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_MUST_ATTACK)
  		e1:SetTargetRange(0, LOCATION_MZONE)
  		e1:SetReset(RESET_PHASE + PHASE_BATTLE)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_MUST_ATTACK_MONSTER)
  		e2:SetValue(s.atklimit)
  		e2:SetLabel(fid)
  		Duel.RegisterEffect(e2, tp)
  		Duel.ChangeAttackTarget(tc)
  	end
  end
  function s.atklimit(e, c)
  	return c:GetRealFieldID() == e:GetLabel()
  end
  
  
source_text: Staunch
  You can only activate this card when your opponent declares an attack. Select 1 face-up monster on your side of the field. During this turn, your opponent can only designate the selected monster as an attack target and your opponent must attack the selected monster with all face-up monsters.
target_text: -- Staunch
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local at = Duel.GetAttackTarget()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() and chkc ~= at
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, at)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, at)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local fid = tc:GetRealFieldID()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_MUST_ATTACK)
  		e1:SetTargetRange(0, LOCATION_MZONE)
  		e1:SetReset(RESET_PHASE + PHASE_BATTLE)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_MUST_ATTACK_MONSTER)
  		e2:SetValue(s.atklimit)
  		e2:SetLabel(fid)
  		Duel.RegisterEffect(e2, tp)
  		Duel.ChangeAttackTarget(tc)
  	end
  end
  function s.atklimit(e, c)
  	return c:GetRealFieldID() == e:GetLabel()
  end
  
  