name: Shift
card_text: When your opponent targets exactly 1 monster you control (and no other cards) for an attack, or with a Spell/Trap effect: Target another monster you control that would be an appropriate target; that attack/Spell/Trap now targets the new target.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--change target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.activate1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetCondition(s.condition2)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.activate2)
  	c:RegisterEffect(e2)
  end
  function s.condition1(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.filter1(c, e)
  	return c:IsCanBeEffectTarget(e)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local ag = eg:GetFirst():GetAttackableTarget()
  	local at = Duel.GetAttackTarget()
  	if chk == 0 then
  		return ag:IsExists(s.filter1, 1, at, e)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = ag:FilterSelect(tp, s.filter1, 1, 1, at, e)
  	Duel.SetTargetCard(g)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and not Duel.GetAttacker():IsImmuneToEffect(e) then
  		Duel.ChangeAttackTarget(tc)
  	end
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() ~= 1 then
  		return false
  	end
  	local tc = g:GetFirst()
  	e:SetLabelObject(tc)
  	return tc:IsControler(tp) and tc:IsLocation(LOCATION_MZONE)
  end
  function s.filter2(c, ct)
  	return Duel.CheckChainTarget(ct, c)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc ~= e:GetLabelObject() and chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter2(chkc, ev)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, e:GetLabelObject(), ev)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, e:GetLabelObject(), ev)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if g:GetFirst():IsRelateToEffect(e) then
  		Duel.ChangeTargetCard(ev, g)
  	end
  end
  
  
source_text: Shift
  When your opponent targets exactly 1 monster you control (and no other cards) for an attack, or with a Spell/Trap effect: Target another monster you control that would be an appropriate target; that attack/Spell/Trap now targets the new target.
target_text: -- Shift
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--change target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.activate1)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetCondition(s.condition2)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.activate2)
  	c:RegisterEffect(e2)
  end
  function s.condition1(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.filter1(c, e)
  	return c:IsCanBeEffectTarget(e)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local ag = eg:GetFirst():GetAttackableTarget()
  	local at = Duel.GetAttackTarget()
  	if chk == 0 then
  		return ag:IsExists(s.filter1, 1, at, e)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = ag:FilterSelect(tp, s.filter1, 1, 1, at, e)
  	Duel.SetTargetCard(g)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and not Duel.GetAttacker():IsImmuneToEffect(e) then
  		Duel.ChangeAttackTarget(tc)
  	end
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() ~= 1 then
  		return false
  	end
  	local tc = g:GetFirst()
  	e:SetLabelObject(tc)
  	return tc:IsControler(tp) and tc:IsLocation(LOCATION_MZONE)
  end
  function s.filter2(c, ct)
  	return Duel.CheckChainTarget(ct, c)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc ~= e:GetLabelObject() and chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter2(chkc, ev)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, e:GetLabelObject(), ev)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, e:GetLabelObject(), ev)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if g:GetFirst():IsRelateToEffect(e) then
  		Duel.ChangeTargetCard(ev, g)
  	end
  end
  
  