name: Number
card_text: 2 Level 4 monsters
  Once per Chain, if 2 or more monsters with the same name are on the field (Quick Effect): You can detach 1 material from this card; choose 1 monster among those with the same name, and destroy all other monsters with that name. Your opponent cannot Summon monsters with the same name as any of the monster(s) chosen for this card's effect. If this card is sent to the GY: You can send 2 "Heraldic Beast" monsters from your Deck to the GY.
external_ids: local SETCARD_ID_0 = 0x76 --Heraldic
  
lua: local SETCARD_ID_0 = 0x76 --Heraldic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 18
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	c:RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and Duel.IsExistingMatchingCard(s.filter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, c, c:GetCode())
  end
  function s.filter(c, code)
  	return c:IsFaceup() and c:IsCode(code)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local dg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, tc, tc:GetCode())
  		Duel.Destroy(dg, REASON_EFFECT)
  		if not c:IsRelateToEffect(e) or c:IsFacedown() then
  			return
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetTargetRange(0, 1)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetLabel(tc:GetCode())
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SUMMON)
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
  		c:RegisterEffect(e3)
  	end
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(e:GetLabel())
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 2, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 2, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(tp, 2, 2, nil)
  		Duel.SendtoGrave(sg, REASON_EFFECT)
  	end
  end
  
  
source_text: Number
  2 Level 4 monsters
  Once per Chain, if 2 or more monsters with the same name are on the field (Quick Effect): You can detach 1 material from this card; choose 1 monster among those with the same name, and destroy all other monsters with that name. Your opponent cannot Summon monsters with the same name as any of the monster(s) chosen for this card's effect. If this card is sent to the GY: You can send 2 "Heraldic Beast" monsters from your Deck to the GY.
target_text: -- Number
  local SETCARD_ID_0 = 0x76 --Heraldic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 18
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	c:RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and Duel.IsExistingMatchingCard(s.filter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, c, c:GetCode())
  end
  function s.filter(c, code)
  	return c:IsFaceup() and c:IsCode(code)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local dg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, tc, tc:GetCode())
  		Duel.Destroy(dg, REASON_EFFECT)
  		if not c:IsRelateToEffect(e) or c:IsFacedown() then
  			return
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetTargetRange(0, 1)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetLabel(tc:GetCode())
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SUMMON)
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
  		c:RegisterEffect(e3)
  	end
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(e:GetLabel())
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 2, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 2, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(tp, 2, 2, nil)
  		Duel.SendtoGrave(sg, REASON_EFFECT)
  	end
  end
  
  