name: War
card_text: If you control no monsters, or all monsters you control are Warrior monsters, you can Normal Summon this card without Tributing. If your EARTH Warrior monster battles, after damage calculation: You can send 1 EARTH Warrior monster from your Deck to the GY, except "War Rock Orpis", then all "War Rock" monsters you currently control gain 200 ATK until the end of your opponent's turn. You can only use this effect of "War Rock Orpis" 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)
  	--normal summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--tograve & atkchange
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_BATTLED)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.tgtg)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFacedown() or not c:IsRace(RACE_WARRIOR)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc == 0
  		and c:IsLevelAbove(5)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and (Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 or not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil))
  end
  function s.tgfilter(c)
  	return c:IsAttribute(ATTRIBUTE_EARTH) and c:IsRace(RACE_WARRIOR) and c:IsAbleToGrave() and not c:IsCode(id)
  end
  function s.check(c, tp)
  	return c and c:IsControler(tp) and c:IsAttribute(ATTRIBUTE_EARTH) and c:IsRace(RACE_WARRIOR)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (s.check(Duel.GetAttacker(), tp) or s.check(Duel.GetAttackTarget(), tp))
  			and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if #g > 0 and Duel.SendtoGrave(g, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		local sg = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  		for tc in aux.Next(sg) 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
  	end
  end
  
  
source_text: War
  If you control no monsters, or all monsters you control are Warrior monsters, you can Normal Summon this card without Tributing. If your EARTH Warrior monster battles, after damage calculation: You can send 1 EARTH Warrior monster from your Deck to the GY, except "War Rock Orpis", then all "War Rock" monsters you currently control gain 200 ATK until the end of your opponent's turn. You can only use this effect of "War Rock Orpis" once per turn.
target_text: -- War
  local SETCARD_ID_0 = 0x15f --War
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--normal summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--tograve & atkchange
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_BATTLED)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.tgtg)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFacedown() or not c:IsRace(RACE_WARRIOR)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc == 0
  		and c:IsLevelAbove(5)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and (Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 or not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil))
  end
  function s.tgfilter(c)
  	return c:IsAttribute(ATTRIBUTE_EARTH) and c:IsRace(RACE_WARRIOR) and c:IsAbleToGrave() and not c:IsCode(id)
  end
  function s.check(c, tp)
  	return c and c:IsControler(tp) and c:IsAttribute(ATTRIBUTE_EARTH) and c:IsRace(RACE_WARRIOR)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (s.check(Duel.GetAttacker(), tp) or s.check(Duel.GetAttackTarget(), tp))
  			and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  			and Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if #g > 0 and Duel.SendtoGrave(g, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		local sg = Duel.GetMatchingGroup(s.atkfilter, tp, LOCATION_MZONE, 0, nil)
  		for tc in aux.Next(sg) 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
  	end
  end
  
  