name: Raider's
card_text: 2 Level 4 DARK monsters
  (This card is always treated as a "The Phantom Knights" and "Raidraptor" card.)
  You can detach 1 material from this card; Special Summon from your Extra Deck, 1 "The Phantom Knights", "Raidraptor", or "Xyz Dragon" Xyz Monster that is 1 Rank higher or lower than this card, by using this face-up card you control as material, but destroy it during your opponent's next End Phase. (This is treated as an Xyz Summon. Transfer its materials to the Summoned monster.) You can only use this effect of "Raider's Knight" once per turn.
external_ids: local SETCARD_ID_0 = 0x10db --The
  
lua: local SETCARD_ID_0 = 0x10db --The
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_DARK), 4, 2)
  	c:EnableReviveLimit()
  	--rank up/down
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.filter(c, e, tp, mc)
  	return c:IsRank(mc:GetRank() + 1, mc:GetRank() - 1)
  		and c:IsSetCard(SETCARD_ID_0, 0xba, 0x2073)
  		and c:IsType(TYPE_XYZ)
  		and mc:IsCanBeXyzMaterial(c)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsControler(tp) and not c:IsImmuneToEffect(e) and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, c)
  		local tc = g:GetFirst()
  		if tc then
  			local mg = c:GetOverlayGroup()
  			if mg:GetCount() > 0 then
  				Duel.Overlay(tc, mg)
  			end
  			tc:SetMaterial(Group.FromCards(c))
  			Duel.Overlay(tc, Group.FromCards(c))
  			if Duel.SpecialSummon(tc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP) ~= 0 then
  				tc:CompleteProcedure()
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  				e1:SetCode(EVENT_PHASE + PHASE_END)
  				e1:SetCountLimit(1)
  				e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  				e1:SetLabelObject(tc)
  				e1:SetCondition(s.descon)
  				e1:SetOperation(s.desop)
  				if Duel.GetTurnPlayer() == 1 - tp and Duel.GetCurrentPhase() == PHASE_END then
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 2)
  					e1:SetLabel(Duel.GetTurnCount())
  					tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 0, 2)
  				else
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  					e1:SetLabel(0)
  					tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 0, 1)
  				end
  				Duel.RegisterEffect(e1, tp)
  			end
  		end
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetTurnPlayer() == tp or Duel.GetTurnCount() == e:GetLabel() then
  		return false
  	end
  	return e:GetLabelObject():GetFlagEffect(id) > 0
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetLabelObject(), REASON_EFFECT)
  end
  
  
source_text: Raider's
  2 Level 4 DARK monsters
  (This card is always treated as a "The Phantom Knights" and "Raidraptor" card.)
  You can detach 1 material from this card; Special Summon from your Extra Deck, 1 "The Phantom Knights", "Raidraptor", or "Xyz Dragon" Xyz Monster that is 1 Rank higher or lower than this card, by using this face-up card you control as material, but destroy it during your opponent's next End Phase. (This is treated as an Xyz Summon. Transfer its materials to the Summoned monster.) You can only use this effect of "Raider's Knight" once per turn.
target_text: -- Raider's
  local SETCARD_ID_0 = 0x10db --The
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_DARK), 4, 2)
  	c:EnableReviveLimit()
  	--rank up/down
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.filter(c, e, tp, mc)
  	return c:IsRank(mc:GetRank() + 1, mc:GetRank() - 1)
  		and c:IsSetCard(SETCARD_ID_0, 0xba, 0x2073)
  		and c:IsType(TYPE_XYZ)
  		and mc:IsCanBeXyzMaterial(c)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsControler(tp) and not c:IsImmuneToEffect(e) and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, c)
  		local tc = g:GetFirst()
  		if tc then
  			local mg = c:GetOverlayGroup()
  			if mg:GetCount() > 0 then
  				Duel.Overlay(tc, mg)
  			end
  			tc:SetMaterial(Group.FromCards(c))
  			Duel.Overlay(tc, Group.FromCards(c))
  			if Duel.SpecialSummon(tc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP) ~= 0 then
  				tc:CompleteProcedure()
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  				e1:SetCode(EVENT_PHASE + PHASE_END)
  				e1:SetCountLimit(1)
  				e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  				e1:SetLabelObject(tc)
  				e1:SetCondition(s.descon)
  				e1:SetOperation(s.desop)
  				if Duel.GetTurnPlayer() == 1 - tp and Duel.GetCurrentPhase() == PHASE_END then
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 2)
  					e1:SetLabel(Duel.GetTurnCount())
  					tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 0, 2)
  				else
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  					e1:SetLabel(0)
  					tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN, 0, 1)
  				end
  				Duel.RegisterEffect(e1, tp)
  			end
  		end
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetTurnPlayer() == tp or Duel.GetTurnCount() == e:GetLabel() then
  		return false
  	end
  	return e:GetLabelObject():GetFlagEffect(id) > 0
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetLabelObject(), REASON_EFFECT)
  end
  
  