name: War
card_text: Gains 100 ATK for each monster your opponent controls. During a Battle Phase in which your EARTH Warrior monster battles (Quick Effect): You can target 1 Level 5 or lower Warrior monster in your GY; Special Summon it, also all "War Rock" monsters you currently control gain 200 ATK until the end of your opponent's turn, also for the rest of this turn, you cannot attack directly with Level 5 or lower monsters. You can only use this effect of "War Rock Skyler" once per turn.
external_ids: local SETCARD_ID_0 = 0x15f --War
  
lua: local SETCARD_ID_0 = 0x15f --War
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.val)
  	c:RegisterEffect(e1)
  	--special summon & atkchange
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.GlobalEffect()
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLE_CONFIRM)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(c)
  	return c and c:IsRace(RACE_WARRIOR) and c:IsAttribute(ATTRIBUTE_EARTH)
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local c0, c1 = Duel.GetBattleMonster(0)
  	if s.check(c0) then
  		Duel.RegisterFlagEffect(0, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if s.check(c1) then
  		Duel.RegisterFlagEffect(1, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.val(e, c)
  	return Duel.GetFieldGroupCount(c:GetControler(), 0, LOCATION_MZONE) * 100
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) > 0 and (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE) and aux.dscon(e, tp, eg, ep, ev, re, r, rp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(5) and 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, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	local g = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  	for tc in aux.Next(g) do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  		e1:SetValue(200)
  		tc:RegisterEffect(e1)
  	end
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsLevelBelow, 5))
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  
  
source_text: War
  Gains 100 ATK for each monster your opponent controls. During a Battle Phase in which your EARTH Warrior monster battles (Quick Effect): You can target 1 Level 5 or lower Warrior monster in your GY; Special Summon it, also all "War Rock" monsters you currently control gain 200 ATK until the end of your opponent's turn, also for the rest of this turn, you cannot attack directly with Level 5 or lower monsters. You can only use this effect of "War Rock Skyler" once per turn.
target_text: -- War
  local SETCARD_ID_0 = 0x15f --War
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.val)
  	c:RegisterEffect(e1)
  	--special summon & atkchange
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		local ge1 = Effect.GlobalEffect()
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_BATTLE_CONFIRM)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  	end
  end
  function s.check(c)
  	return c and c:IsRace(RACE_WARRIOR) and c:IsAttribute(ATTRIBUTE_EARTH)
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local c0, c1 = Duel.GetBattleMonster(0)
  	if s.check(c0) then
  		Duel.RegisterFlagEffect(0, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  	if s.check(c1) then
  		Duel.RegisterFlagEffect(1, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.val(e, c)
  	return Duel.GetFieldGroupCount(c:GetControler(), 0, LOCATION_MZONE) * 100
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) > 0 and (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE) and aux.dscon(e, tp, eg, ep, ev, re, r, rp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(5) and 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, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	local g = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  	for tc in aux.Next(g) do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_OPPO_TURN)
  		e1:SetValue(200)
  		tc:RegisterEffect(e1)
  	end
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsLevelBelow, 5))
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  
  