name: Ally
card_text: If a LIGHT monster is on the field, destroy this card. At the start of the Damage Step, if this card attacks a face-down Defense Position monster: Destroy that face-down monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_BATTLE_START)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--self destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_SELF_DESTROY)
  	e2:SetCondition(s.sdcon)
  	c:RegisterEffect(e2)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return e:GetHandler() == Duel.GetAttacker() and d and d:IsFacedown() and d:IsDefensePos()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, Duel.GetAttackTarget(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if d:IsRelateToBattle() then
  		Duel.Destroy(d, REASON_EFFECT)
  	end
  end
  function s.sdfilter(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.sdcon(e)
  	return Duel.IsExistingMatchingCard(s.sdfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  
  
source_text: Ally
  If a LIGHT monster is on the field, destroy this card. At the start of the Damage Step, if this card attacks a face-down Defense Position monster: Destroy that face-down monster.
target_text: -- Ally
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_BATTLE_START)
  	e1:SetCondition(s.descon)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--self destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_SELF_DESTROY)
  	e2:SetCondition(s.sdcon)
  	c:RegisterEffect(e2)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return e:GetHandler() == Duel.GetAttacker() and d and d:IsFacedown() and d:IsDefensePos()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, Duel.GetAttackTarget(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	if d:IsRelateToBattle() then
  		Duel.Destroy(d, REASON_EFFECT)
  	end
  end
  function s.sdfilter(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.sdcon(e)
  	return Duel.IsExistingMatchingCard(s.sdfilter, 0, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  
  