name: Mitsu
card_text: If you control a "Ninja" card or a face-down Defense Position monster: You can Special Summon this card from your hand. When your opponent activates a monster effect (Quick Effect): You can target 1 face-down Defense Position monster you control; change it to face-up Defense Position, and if you do, change this card to face-down Defense Position, then, if the targeted monster was a "Ninja" monster, except "Mitsu the Insect Ninja", negate that opponent's activated effect. You can only use each effect of "Mitsu the Insect Ninja" once per turn.
external_ids: local SETCARD_ID_0 = 0x2b --Ninja
  
lua: local SETCARD_ID_0 = 0x2b --Ninja
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_POSITION + CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) or c:IsLocation(LOCATION_MZONE) and c:IsPosition(POS_FACEDOWN_DEFENSE)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep == 1 - tp and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainDisablable(ev) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  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 chkc:IsPosition(POS_FACEDOWN_DEFENSE)
  	end
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsPosition, tp, LOCATION_MZONE, 0, 1, nil, POS_FACEDOWN_DEFENSE) and c:IsCanTurnSet()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEDOWN)
  	local g = Duel.SelectTarget(tp, Card.IsPosition, tp, LOCATION_MZONE, 0, 1, 1, nil, POS_FACEDOWN_DEFENSE)
  	g:AddCard(c)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsLocation(LOCATION_MZONE) and tc:IsFacedown() and Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) > 0 then
  		local c = e:GetHandler()
  		if c:IsRelateToEffect(e) and c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and Duel.ChangePosition(c, POS_FACEDOWN_DEFENSE) > 0 and tc:IsSetCard(SETCARD_ID_0) and not tc:IsCode(id) then
  			Duel.BreakEffect()
  			Duel.NegateEffect(ev)
  		end
  	end
  end
  
  
source_text: Mitsu
  If you control a "Ninja" card or a face-down Defense Position monster: You can Special Summon this card from your hand. When your opponent activates a monster effect (Quick Effect): You can target 1 face-down Defense Position monster you control; change it to face-up Defense Position, and if you do, change this card to face-down Defense Position, then, if the targeted monster was a "Ninja" monster, except "Mitsu the Insect Ninja", negate that opponent's activated effect. You can only use each effect of "Mitsu the Insect Ninja" once per turn.
target_text: -- Mitsu
  local SETCARD_ID_0 = 0x2b --Ninja
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_POSITION + CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) or c:IsLocation(LOCATION_MZONE) and c:IsPosition(POS_FACEDOWN_DEFENSE)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep == 1 - tp and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainDisablable(ev) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  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 chkc:IsPosition(POS_FACEDOWN_DEFENSE)
  	end
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsPosition, tp, LOCATION_MZONE, 0, 1, nil, POS_FACEDOWN_DEFENSE) and c:IsCanTurnSet()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEDOWN)
  	local g = Duel.SelectTarget(tp, Card.IsPosition, tp, LOCATION_MZONE, 0, 1, 1, nil, POS_FACEDOWN_DEFENSE)
  	g:AddCard(c)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, 2, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsLocation(LOCATION_MZONE) and tc:IsFacedown() and Duel.ChangePosition(tc, POS_FACEUP_DEFENSE) > 0 then
  		local c = e:GetHandler()
  		if c:IsRelateToEffect(e) and c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and Duel.ChangePosition(c, POS_FACEDOWN_DEFENSE) > 0 and tc:IsSetCard(SETCARD_ID_0) and not tc:IsCode(id) then
  			Duel.BreakEffect()
  			Duel.NegateEffect(ev)
  		end
  	end
  end
  
  