name: Gladiator
card_text: 2 Level 5 or higher "Gladiator Beast" monsters
  Must first be Special Summoned (from your Extra Deck) by shuffling the above cards you control into the Deck. Cannot be used as Fusion Material. Once per turn: You can Special Summon 1 "Gladiator Beast" Fusion Monster from your Extra Deck, except "Gladiator Beast Tamer Editor", ignoring its Summoning conditions. At the end of the Battle Phase, if your "Gladiator Beast" monster battled: You can shuffle that monster into the Deck or Extra Deck; Special Summon 1 "Gladiator Beast" monster from your Deck.
external_ids: local SETCARD_ID_0 = 0x1019 --Gladiator
  
lua: local SETCARD_ID_0 = 0x1019 --Gladiator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFunRep(c, s.matfilter, 2, true)
  	aux.AddContactFusionProcedure(c, Card.IsAbleToDeckOrExtraAsCost, LOCATION_MZONE, 0, aux.ContactFusionSendToDeck(c))
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--cannot be fusion material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--special summon (extra)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 3))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetTarget(s.esptg)
  	e4:SetOperation(s.espop)
  	c:RegisterEffect(e4)
  	--special summon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 4))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetCountLimit(1)
  	e6:SetCost(s.spcost)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  end
  function s.matfilter(c)
  	return c:IsLevelAbove(5) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  function s.splimit(e, se, sp, st)
  	return e:GetHandler():GetLocation() ~= LOCATION_EXTRA
  end
  function s.espfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FUSION) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.esptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.espfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.espop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.espfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, true, false, POS_FACEUP)
  	end
  end
  function s.spcfilter(c, ft)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetBattledGroupCount() > 0 and c:IsAbleToDeckOrExtraAsCost() and (ft > 0 or c:GetSequence() < 5)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return ft > -1 and Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_MZONE, 0, 1, nil, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, ft)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		tc:RegisterFlagEffect(tc:GetOriginalCode(), RESET_EVENT + RESETS_STANDARD + RESET_DISABLE, 0, 0)
  		Duel.SpecialSummonComplete()
  	end
  end
  
  
source_text: Gladiator
  2 Level 5 or higher "Gladiator Beast" monsters
  Must first be Special Summoned (from your Extra Deck) by shuffling the above cards you control into the Deck. Cannot be used as Fusion Material. Once per turn: You can Special Summon 1 "Gladiator Beast" Fusion Monster from your Extra Deck, except "Gladiator Beast Tamer Editor", ignoring its Summoning conditions. At the end of the Battle Phase, if your "Gladiator Beast" monster battled: You can shuffle that monster into the Deck or Extra Deck; Special Summon 1 "Gladiator Beast" monster from your Deck.
target_text: -- Gladiator
  local SETCARD_ID_0 = 0x1019 --Gladiator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFunRep(c, s.matfilter, 2, true)
  	aux.AddContactFusionProcedure(c, Card.IsAbleToDeckOrExtraAsCost, LOCATION_MZONE, 0, aux.ContactFusionSendToDeck(c))
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--cannot be fusion material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--special summon (extra)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 3))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetTarget(s.esptg)
  	e4:SetOperation(s.espop)
  	c:RegisterEffect(e4)
  	--special summon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 4))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetCountLimit(1)
  	e6:SetCost(s.spcost)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  end
  function s.matfilter(c)
  	return c:IsLevelAbove(5) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  function s.splimit(e, se, sp, st)
  	return e:GetHandler():GetLocation() ~= LOCATION_EXTRA
  end
  function s.espfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FUSION) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.esptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.espfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.espop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.espfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, true, false, POS_FACEUP)
  	end
  end
  function s.spcfilter(c, ft)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetBattledGroupCount() > 0 and c:IsAbleToDeckOrExtraAsCost() and (ft > 0 or c:GetSequence() < 5)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return ft > -1 and Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_MZONE, 0, 1, nil, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, ft)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  		tc:RegisterFlagEffect(tc:GetOriginalCode(), RESET_EVENT + RESETS_STANDARD + RESET_DISABLE, 0, 0)
  		Duel.SpecialSummonComplete()
  	end
  end
  
  