name: Heroic
card_text: Special Summon 1 Warrior monster from your hand or GY, but if you Special Summoned a non-"Heroic" monster by this effect, negate its effects, also it cannot attack. If your LP are 500 or less: You can banish this card from your GY, then target 1 face-up monster you control; it gains 500 ATK for each "Heroic" card you currently control, and for each "Heroic" card attached to Xyz Monsters you currently control. You can only activate 1 "Heroic Call" per turn.
external_ids: local SETCARD_ID_0 = 0x6f --Heroic
  
lua: local SETCARD_ID_0 = 0x6f --Heroic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCondition(s.atkcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_WARRIOR) 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.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE + LOCATION_HAND)
  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 tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE + LOCATION_HAND, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) and not tc:IsSetCard(SETCARD_ID_0) then
  		local c = e:GetHandler()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_ATTACK)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e3)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetLP(tp) <= 500
  end
  function s.afilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	local ct1 = Duel.GetMatchingGroupCount(s.afilter, tp, LOCATION_ONFIELD, 0, nil)
  	local ct2 = Duel.GetOverlayGroup(tp, 1, 0):FilterCount(Card.IsSetCard, nil, 0x6f)
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, nil) and ct1 + ct2 > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local ct1 = Duel.GetMatchingGroupCount(s.afilter, tp, LOCATION_ONFIELD, 0, nil)
  		local ct2 = Duel.GetOverlayGroup(tp, 1, 0):FilterCount(Card.IsSetCard, nil, 0x6f)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue((ct1 + ct2) * 500)
  		tc:RegisterEffect(e1)
  	end
  end
  
  
source_text: Heroic
  Special Summon 1 Warrior monster from your hand or GY, but if you Special Summoned a non-"Heroic" monster by this effect, negate its effects, also it cannot attack. If your LP are 500 or less: You can banish this card from your GY, then target 1 face-up monster you control; it gains 500 ATK for each "Heroic" card you currently control, and for each "Heroic" card attached to Xyz Monsters you currently control. You can only activate 1 "Heroic Call" per turn.
target_text: -- Heroic
  local SETCARD_ID_0 = 0x6f --Heroic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCondition(s.atkcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, e, tp)
  	return c:IsRace(RACE_WARRIOR) 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.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE + LOCATION_HAND)
  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 tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE + LOCATION_HAND, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) and not tc:IsSetCard(SETCARD_ID_0) then
  		local c = e:GetHandler()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_ATTACK)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e3)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetLP(tp) <= 500
  end
  function s.afilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	local ct1 = Duel.GetMatchingGroupCount(s.afilter, tp, LOCATION_ONFIELD, 0, nil)
  	local ct2 = Duel.GetOverlayGroup(tp, 1, 0):FilterCount(Card.IsSetCard, nil, 0x6f)
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, nil) and ct1 + ct2 > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local ct1 = Duel.GetMatchingGroupCount(s.afilter, tp, LOCATION_ONFIELD, 0, nil)
  		local ct2 = Duel.GetOverlayGroup(tp, 1, 0):FilterCount(Card.IsSetCard, nil, 0x6f)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue((ct1 + ct2) * 500)
  		tc:RegisterEffect(e1)
  	end
  end
  
  