name: Heroic
card_text: 2 Level 4 Warrior monsters
  Your opponent cannot target monsters for attacks, except this one. You can only use each of the following effects of "Heroic Champion - Claivesolish" once per turn. You can pay LP so that you only have 500 left; at the start of the Battle Phase this turn, double the ATK of 1 monster you control. When an attack is declared involving your opponent's monster: You can detach 1 material from this card, then target 1 face-up monster your opponent controls; this card gains ATK equal to that monster's ATK until the end of this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR), 4, 2)
  	c:EnableReviveLimit()
  	--atk limit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetValue(s.atklimit)
  	c:RegisterEffect(e1)
  	--atk double
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.dbcon)
  	e2:SetCost(s.dbcost)
  	e2:SetOperation(s.dbop)
  	c:RegisterEffect(e2)
  	--atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCondition(s.upcon)
  	e3:SetCost(s.upcost)
  	e3:SetTarget(s.uptg)
  	e3:SetOperation(s.upop)
  	c:RegisterEffect(e3)
  end
  function s.atklimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.dbcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsAbleToEnterBP()
  end
  function s.dbcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local lp = Duel.GetLP(tp)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, lp - 500)
  	end
  	Duel.PayLPCost(tp, lp - 500)
  end
  function s.dbop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.sop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.sop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		local tc = sg:GetFirst()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(tc:GetAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.upcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetBattleMonster(1 - tp)
  	return tc and tc:IsRelateToBattle()
  end
  function s.upcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.uptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and aux.nzatk(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.nzatk, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, aux.nzatk, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.upop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel:GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetAttack())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Heroic
  2 Level 4 Warrior monsters
  Your opponent cannot target monsters for attacks, except this one. You can only use each of the following effects of "Heroic Champion - Claivesolish" once per turn. You can pay LP so that you only have 500 left; at the start of the Battle Phase this turn, double the ATK of 1 monster you control. When an attack is declared involving your opponent's monster: You can detach 1 material from this card, then target 1 face-up monster your opponent controls; this card gains ATK equal to that monster's ATK until the end of this turn.
target_text: -- Heroic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR), 4, 2)
  	c:EnableReviveLimit()
  	--atk limit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetValue(s.atklimit)
  	c:RegisterEffect(e1)
  	--atk double
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.dbcon)
  	e2:SetCost(s.dbcost)
  	e2:SetOperation(s.dbop)
  	c:RegisterEffect(e2)
  	--atk up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCondition(s.upcon)
  	e3:SetCost(s.upcost)
  	e3:SetTarget(s.uptg)
  	e3:SetOperation(s.upop)
  	c:RegisterEffect(e3)
  end
  function s.atklimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.dbcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsAbleToEnterBP()
  end
  function s.dbcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local lp = Duel.GetLP(tp)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, lp - 500)
  	end
  	Duel.PayLPCost(tp, lp - 500)
  end
  function s.dbop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_BATTLE_START)
  	e1:SetCountLimit(1)
  	e1:SetOperation(s.sop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.sop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		local tc = sg:GetFirst()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(tc:GetAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.upcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetBattleMonster(1 - tp)
  	return tc and tc:IsRelateToBattle()
  end
  function s.upcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.uptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and aux.nzatk(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.nzatk, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, aux.nzatk, tp, 0, LOCATION_MZONE, 1, 1, nil)
  end
  function s.upop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel:GetFirstTarget()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(tc:GetAttack())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  