name: Heraldic
card_text: You can send 1 "Heraldic Beast" monster from your Deck to the GY, except "Heraldic Beast Gryphon"; Special Summon this card from your hand, also you cannot Special Summon from the Extra Deck for the rest of this turn, except by Xyz Summon that uses only monsters with "Heraldic Beast" or "Number" in their original names as material. Can be treated as 2 materials for the Xyz Summon of a "Number" Xyz Monster that requires 3 or more materials. You can only use each effect of "Heraldic Beast Gryphon" once per turn.
external_ids: local SETCARD_ID_0 = 0x76 --Heraldic
  local SETCARD_ID_1 = 0x48 --Number
  
lua: local SETCARD_ID_0 = 0x76 --Heraldic
  local SETCARD_ID_1 = 0x48 --Number
  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:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--2X material
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_DOUBLE_XMATERIAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.sxyzfilter)
  	e2:SetValue(id)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 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
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	--material limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_RANGE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(0x7f, 0x7f)
  	e2:SetTarget(s.tlmtg)
  	e2:SetValue(s.tlmval)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  	--must material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(67120578)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsLocation(LOCATION_EXTRA) and bit.band(sumtype, SUMMON_TYPE_XYZ) ~= SUMMON_TYPE_XYZ
  end
  function s.tlmtg(e, c)
  	return not c:IsOriginalSetCard(SETCARD_ID_1, 0x48)
  end
  function s.tlmval(e, c)
  	if not c then
  		return false
  	end
  	return c:GetControler() == e:GetOwnerPlayer()
  end
  function s.sxyzfilter(e, c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  
  
source_text: Heraldic
  You can send 1 "Heraldic Beast" monster from your Deck to the GY, except "Heraldic Beast Gryphon"; Special Summon this card from your hand, also you cannot Special Summon from the Extra Deck for the rest of this turn, except by Xyz Summon that uses only monsters with "Heraldic Beast" or "Number" in their original names as material. Can be treated as 2 materials for the Xyz Summon of a "Number" Xyz Monster that requires 3 or more materials. You can only use each effect of "Heraldic Beast Gryphon" once per turn.
target_text: -- Heraldic
  local SETCARD_ID_0 = 0x76 --Heraldic
  local SETCARD_ID_1 = 0x48 --Number
  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:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--2X material
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_DOUBLE_XMATERIAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.sxyzfilter)
  	e2:SetValue(id)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  end
  function s.costfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 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
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	--material limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_RANGE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(0x7f, 0x7f)
  	e2:SetTarget(s.tlmtg)
  	e2:SetValue(s.tlmval)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  	--must material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(67120578)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsLocation(LOCATION_EXTRA) and bit.band(sumtype, SUMMON_TYPE_XYZ) ~= SUMMON_TYPE_XYZ
  end
  function s.tlmtg(e, c)
  	return not c:IsOriginalSetCard(SETCARD_ID_1, 0x48)
  end
  function s.tlmval(e, c)
  	if not c then
  		return false
  	end
  	return c:GetControler() == e:GetOwnerPlayer()
  end
  function s.sxyzfilter(e, c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  
  