name: Battle
card_text: Each player can Special Summon 1 monster from their GY that was destroyed by battle this turn, in Attack Position, and if you Special Summoned "Elemental HERO Neos" by this effect, if it battles your opponent's monster this turn, its ATK becomes doubled during the Damage Step only. You can only activate 1 "Battle of Sleeping Spirits" per turn.
external_ids: local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  
lua: local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.AddSetNameMonsterList(c, SETCARD_ID_0)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp, tid)
  	return c:GetTurnID() == tid and c:IsReason(REASON_BATTLE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
  end
  function s.target(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, 0, 1, nil, e, tp, Duel.GetTurnCount()))
  			or (Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_GRAVE, 1, nil, e, 1 - tp, Duel.GetTurnCount()))
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, PLAYER_ALL, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE, 0, nil, e, tp, Duel.GetTurnCount())
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP_ATTACK)
  			if tc:IsCode(CARD_ID_0) then
  				local e1 = Effect.CreateEffect(e:GetHandler())
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  				e1:SetRange(LOCATION_MZONE)
  				e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  				e1:SetCondition(s.atkcon)
  				e1:SetValue(s.atkval)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e1)
  			end
  		end
  	end
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, 1 - tp) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), 1 - tp, LOCATION_GRAVE, 0, nil, e, 1 - tp, Duel.GetTurnCount())
  		if g:GetCount() > 0 and Duel.SelectYesNo(1 - tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(1 - tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummonStep(tc, 0, 1 - tp, 1 - tp, false, false, POS_FACEUP_ATTACK)
  		end
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.atkcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local a, d = Duel.GetBattleMonster(0)
  	if (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and (a == e:GetHandler() and d or a and d == e:GetHandler()) then
  		e:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL + PHASE_END)
  		return true
  	end
  	return false
  end
  function s.atkval(e, c)
  	return e:GetHandler():GetAttack() * 2
  end
  
  
source_text: Battle
  Each player can Special Summon 1 monster from their GY that was destroyed by battle this turn, in Attack Position, and if you Special Summoned "Elemental HERO Neos" by this effect, if it battles your opponent's monster this turn, its ATK becomes doubled during the Damage Step only. You can only activate 1 "Battle of Sleeping Spirits" per turn.
target_text: -- Battle
  local CARD_ID_0 = 89943723 --Elemental HERO Neos
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	aux.AddSetNameMonsterList(c, SETCARD_ID_0)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp, tid)
  	return c:GetTurnID() == tid and c:IsReason(REASON_BATTLE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
  end
  function s.target(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, 0, 1, nil, e, tp, Duel.GetTurnCount()))
  			or (Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_GRAVE, 1, nil, e, 1 - tp, Duel.GetTurnCount()))
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, PLAYER_ALL, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE, 0, nil, e, tp, Duel.GetTurnCount())
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP_ATTACK)
  			if tc:IsCode(CARD_ID_0) then
  				local e1 = Effect.CreateEffect(e:GetHandler())
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  				e1:SetRange(LOCATION_MZONE)
  				e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  				e1:SetCondition(s.atkcon)
  				e1:SetValue(s.atkval)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e1)
  			end
  		end
  	end
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, 1 - tp) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), 1 - tp, LOCATION_GRAVE, 0, nil, e, 1 - tp, Duel.GetTurnCount())
  		if g:GetCount() > 0 and Duel.SelectYesNo(1 - tp, aux.Stringid(id, 0)) then
  			Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_SPSUMMON)
  			local tc = g:Select(1 - tp, 1, 1, nil):GetFirst()
  			Duel.SpecialSummonStep(tc, 0, 1 - tp, 1 - tp, false, false, POS_FACEUP_ATTACK)
  		end
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.atkcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local a, d = Duel.GetBattleMonster(0)
  	if (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and (a == e:GetHandler() and d or a and d == e:GetHandler()) then
  		e:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE_CAL + PHASE_END)
  		return true
  	end
  	return false
  end
  function s.atkval(e, c)
  	return e:GetHandler():GetAttack() * 2
  end
  
  