name: Invincibility
card_text: Once per turn: You can banish 1 face-up Ritual, Fusion, Synchro, Xyz, Pendulum, or Link Monster you control; this turn, the effects of monsters with the same card type as that banished monster (Ritual, Fusion, Synchro, Xyz, Pendulum, or Link) are negated.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCountLimit(1)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsType(0x58020C0) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local tc = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil):GetFirst()
  	Duel.Remove(tc, POS_FACEUP, REASON_COST)
  	local flag = 0
  	if tc:IsType(TYPE_RITUAL) then
  		flag = bit.bor(flag, TYPE_RITUAL)
  	end
  	if tc:IsType(TYPE_FUSION) then
  		flag = bit.bor(flag, TYPE_FUSION)
  	end
  	if tc:IsType(TYPE_SYNCHRO) then
  		flag = bit.bor(flag, TYPE_SYNCHRO)
  	end
  	if tc:IsType(TYPE_XYZ) then
  		flag = bit.bor(flag, TYPE_XYZ)
  	end
  	if tc:IsType(TYPE_PENDULUM) then
  		flag = bit.bor(flag, TYPE_PENDULUM)
  	end
  	if tc:IsType(TYPE_LINK) then
  		flag = bit.bor(flag, TYPE_LINK)
  	end
  	e:SetLabel(flag)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	local flag = e:GetLabel()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.distg)
  	e1:SetCondition(s.discon)
  	e1:SetLabel(flag)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.distg(e, c)
  	return c:IsType(e:GetLabel())
  end
  function s.discon(e)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  end
  
  
source_text: Invincibility
  Once per turn: You can banish 1 face-up Ritual, Fusion, Synchro, Xyz, Pendulum, or Link Monster you control; this turn, the effects of monsters with the same card type as that banished monster (Ritual, Fusion, Synchro, Xyz, Pendulum, or Link) are negated.
target_text: -- Invincibility
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Activate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetCountLimit(1)
  	e2:SetCost(s.cost)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsType(0x58020C0) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local tc = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil):GetFirst()
  	Duel.Remove(tc, POS_FACEUP, REASON_COST)
  	local flag = 0
  	if tc:IsType(TYPE_RITUAL) then
  		flag = bit.bor(flag, TYPE_RITUAL)
  	end
  	if tc:IsType(TYPE_FUSION) then
  		flag = bit.bor(flag, TYPE_FUSION)
  	end
  	if tc:IsType(TYPE_SYNCHRO) then
  		flag = bit.bor(flag, TYPE_SYNCHRO)
  	end
  	if tc:IsType(TYPE_XYZ) then
  		flag = bit.bor(flag, TYPE_XYZ)
  	end
  	if tc:IsType(TYPE_PENDULUM) then
  		flag = bit.bor(flag, TYPE_PENDULUM)
  	end
  	if tc:IsType(TYPE_LINK) then
  		flag = bit.bor(flag, TYPE_LINK)
  	end
  	e:SetLabel(flag)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	local flag = e:GetLabel()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.distg)
  	e1:SetCondition(s.discon)
  	e1:SetLabel(flag)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.distg(e, c)
  	return c:IsType(e:GetLabel())
  end
  function s.discon(e)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  end
  
  