name: Ally
card_text: This card can attack all face-up LIGHT monsters your opponent controls once each. If this card battles a non-LIGHT monster, destroy this card before damage calculation.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--attack all
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_ATTACK_ALL)
  	e1:SetValue(s.atkfilter)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.atkfilter(e, c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local c = e:GetHandler()
  		local a = Duel.GetAttacker()
  		if a == c then
  			a = Duel.GetAttackTarget()
  		end
  		return a and a:IsNonAttribute(ATTRIBUTE_LIGHT)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToBattle() then
  		Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  	end
  end
  
  
source_text: Ally
  This card can attack all face-up LIGHT monsters your opponent controls once each. If this card battles a non-LIGHT monster, destroy this card before damage calculation.
target_text: -- Ally
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--attack all
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_ATTACK_ALL)
  	e1:SetValue(s.atkfilter)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.atkfilter(e, c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local c = e:GetHandler()
  		local a = Duel.GetAttacker()
  		if a == c then
  			a = Duel.GetAttackTarget()
  		end
  		return a and a:IsNonAttribute(ATTRIBUTE_LIGHT)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToBattle() then
  		Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  	end
  end
  
  