name: Ninjitsu
card_text: Tribute 1 "Ninja" monster to target 1 monster your opponent controls; banish that target. While that card is banished, its Monster Card Zone cannot be used. When this face-up card leaves the field: Return the card banished by this effect to the same Monster Card Zone, in the same battle position.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--return
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_LEAVE_FIELD)
  	e2:SetCondition(s.retcon)
  	e2:SetOperation(s.retop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0x2b)
  	end
  	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0x2b)
  	Duel.Release(g, REASON_COST)
  end
  function s.filter(c)
  	return c:IsAbleToRemove()
  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 s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	local val = aux.SequenceToGlobal(tc:GetControler(), LOCATION_MZONE, tc:GetSequence())
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, 0, REASON_EFFECT + REASON_TEMPORARY) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_DISABLE_FIELD)
  		e1:SetRange(LOCATION_SZONE)
  		e1:SetCondition(s.discon)
  		e1:SetValue(val)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.discon(e)
  	return e:GetHandler():GetCardTargetCount() > 0
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if tc and tc:IsLocation(LOCATION_REMOVED) then
  		e:SetLabelObject(tc)
  		tc:CreateEffectRelation(e)
  		return true
  	else
  		return false
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = e:GetLabelObject()
  	if tc:IsRelateToEffect(e) then
  		local zone = 0x1 << tc:GetPreviousSequence()
  		Duel.ReturnToField(tc, tc:GetPreviousPosition(), zone)
  	end
  end
  
  
source_text: Ninjitsu
  Tribute 1 "Ninja" monster to target 1 monster your opponent controls; banish that target. While that card is banished, its Monster Card Zone cannot be used. When this face-up card leaves the field: Return the card banished by this effect to the same Monster Card Zone, in the same battle position.
target_text: -- Ninjitsu
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--return
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_LEAVE_FIELD)
  	e2:SetCondition(s.retcon)
  	e2:SetOperation(s.retop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, Card.IsSetCard, 1, nil, 0x2b)
  	end
  	local g = Duel.SelectReleaseGroup(tp, Card.IsSetCard, 1, 1, nil, 0x2b)
  	Duel.Release(g, REASON_COST)
  end
  function s.filter(c)
  	return c:IsAbleToRemove()
  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 s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	local val = aux.SequenceToGlobal(tc:GetControler(), LOCATION_MZONE, tc:GetSequence())
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, 0, REASON_EFFECT + REASON_TEMPORARY) ~= 0 and tc:IsLocation(LOCATION_REMOVED) then
  		c:SetCardTarget(tc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_DISABLE_FIELD)
  		e1:SetRange(LOCATION_SZONE)
  		e1:SetCondition(s.discon)
  		e1:SetValue(val)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.discon(e)
  	return e:GetHandler():GetCardTargetCount() > 0
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if tc and tc:IsLocation(LOCATION_REMOVED) then
  		e:SetLabelObject(tc)
  		tc:CreateEffectRelation(e)
  		return true
  	else
  		return false
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = e:GetLabelObject()
  	if tc:IsRelateToEffect(e) then
  		local zone = 0x1 << tc:GetPreviousSequence()
  		Duel.ReturnToField(tc, tc:GetPreviousPosition(), zone)
  	end
  end
  
  