name: War
card_text: During the Main Phase, if a face-up "War Rock" monster(s) you control leaves the field by an opponent's card effect: Destroy up to 2 cards your opponent controls. You can only activate 1 "War Rock Big Blow" 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)
  	--Destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_LEAVE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tp, rp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler() == tp and c:IsPreviousLocation(LOCATION_MZONE) and rp == 1 - tp and c:IsReason(REASON_EFFECT)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return (ph == PHASE_MAIN1 or ph == PHASE_MAIN2) and eg:IsExists(s.cfilter, 1, nil, tp, rp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 2, nil)
  	if #g > 0 then
  		Duel.HintSelection(g)
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  
source_text: War
  During the Main Phase, if a face-up "War Rock" monster(s) you control leaves the field by an opponent's card effect: Destroy up to 2 cards your opponent controls. You can only activate 1 "War Rock Big Blow" per turn.
target_text: -- War
  local SETCARD_ID_0 = 0x15f --War
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_LEAVE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tp, rp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler() == tp and c:IsPreviousLocation(LOCATION_MZONE) and rp == 1 - tp and c:IsReason(REASON_EFFECT)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return (ph == PHASE_MAIN1 or ph == PHASE_MAIN2) and eg:IsExists(s.cfilter, 1, nil, tp, rp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 2, nil)
  	if #g > 0 then
  		Duel.HintSelection(g)
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  