name: Xtra
card_text: 2 "HERO" monsters
  If this card is Link Summoned: You can reveal 1 "HERO" Fusion Monster in your Extra Deck, and if you do, add up to 2 of the Fusion Materials mentioned on that card, with different names, from your Deck to your hand. You cannot Special Summon monsters the turn you activate this effect, except "HERO" monsters. You can only use this effect of "Xtra HERO Infernal Devicer" once per turn. Fiend monsters this card points to gain ATK/DEF equal to its Level x 100.
external_ids: local SETCARD_ID_0 = 0x8 --HERO
  
lua: local SETCARD_ID_0 = 0x8 --HERO
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetCost(s.thcost)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--atk/def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.ffilter(c, tp)
  	return c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil, c)
  end
  function s.thfilter(c, fc)
  	return aux.IsMaterialListCode(fc, c:GetCode()) and c:IsAbleToHand() and c:IsType(TYPE_MONSTER)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.ffilter, tp, LOCATION_EXTRA, 0, 1, nil, tp)
  	end
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local tc = Duel.SelectMatchingCard(tp, s.ffilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, tp):GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, tc)
  		local sg = g:SelectSubGroup(tp, aux.dncheck, false, 1, 2)
  		if sg and sg:GetCount() > 0 then
  			Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  		end
  	end
  end
  function s.atktg(e, c)
  	return e:GetHandler():GetLinkedGroup():IsContains(c) and c:IsRace(RACE_FIEND)
  end
  function s.atkval(e, c)
  	return c:GetLevel() * 100
  end
  
  
source_text: Xtra
  2 "HERO" monsters
  If this card is Link Summoned: You can reveal 1 "HERO" Fusion Monster in your Extra Deck, and if you do, add up to 2 of the Fusion Materials mentioned on that card, with different names, from your Deck to your hand. You cannot Special Summon monsters the turn you activate this effect, except "HERO" monsters. You can only use this effect of "Xtra HERO Infernal Devicer" once per turn. Fiend monsters this card points to gain ATK/DEF equal to its Level x 100.
target_text: -- Xtra
  local SETCARD_ID_0 = 0x8 --HERO
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetCost(s.thcost)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--atk/def
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.ffilter(c, tp)
  	return c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil, c)
  end
  function s.thfilter(c, fc)
  	return aux.IsMaterialListCode(fc, c:GetCode()) and c:IsAbleToHand() and c:IsType(TYPE_MONSTER)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.ffilter, tp, LOCATION_EXTRA, 0, 1, nil, tp)
  	end
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local tc = Duel.SelectMatchingCard(tp, s.ffilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, tp):GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, tc)
  		local sg = g:SelectSubGroup(tp, aux.dncheck, false, 1, 2)
  		if sg and sg:GetCount() > 0 then
  			Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  		end
  	end
  end
  function s.atktg(e, c)
  	return e:GetHandler():GetLinkedGroup():IsContains(c) and c:IsRace(RACE_FIEND)
  end
  function s.atkval(e, c)
  	return c:GetLevel() * 100
  end
  
  