name: Lightray
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by having 5 or more LIGHT monsters with different names in your Graveyard, and cannot be Special Summoned by other ways. Once per turn, during either player's turn, when a Spell/Trap Card is activated: You can banish 1 Warrior-Type monster from your Graveyard; negate the activation, and if you do, destroy it. All face-up monsters you control must be Warrior-Type to activate and to resolve this effect.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--spsummon limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e2)
  	--negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetCondition(s.negcon)
  	e3:SetCost(s.negcost)
  	e3:SetTarget(s.negtg)
  	e3:SetOperation(s.negop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	if Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(Card.IsAttribute, c:GetControler(), LOCATION_GRAVE, 0, nil, ATTRIBUTE_LIGHT)
  	local ct = g:GetClassCount(Card.GetCode)
  	return ct > 4
  end
  function s.cfilter(c)
  	return c:IsFaceup() and not c:IsRace(RACE_WARRIOR)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and re:IsHasType(EFFECT_TYPE_ACTIVATE)
  		and Duel.IsChainNegatable(ev)
  		and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.cfilter2(c)
  	return c:IsRace(RACE_WARRIOR) and c:IsAbleToRemove()
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.cfilter3(c)
  	return c:IsFaceup() and c:IsRace(RACE_WARRIOR)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) or not Duel.IsExistingMatchingCard(s.cfilter3, tp, LOCATION_MZONE, 0, 1, nil) then
  		return
  	end
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  
source_text: Lightray
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by having 5 or more LIGHT monsters with different names in your Graveyard, and cannot be Special Summoned by other ways. Once per turn, during either player's turn, when a Spell/Trap Card is activated: You can banish 1 Warrior-Type monster from your Graveyard; negate the activation, and if you do, destroy it. All face-up monsters you control must be Warrior-Type to activate and to resolve this effect.
target_text: -- Lightray
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--spsummon limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e2)
  	--negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetCondition(s.negcon)
  	e3:SetCost(s.negcost)
  	e3:SetTarget(s.negtg)
  	e3:SetOperation(s.negop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	if Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(Card.IsAttribute, c:GetControler(), LOCATION_GRAVE, 0, nil, ATTRIBUTE_LIGHT)
  	local ct = g:GetClassCount(Card.GetCode)
  	return ct > 4
  end
  function s.cfilter(c)
  	return c:IsFaceup() and not c:IsRace(RACE_WARRIOR)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and re:IsHasType(EFFECT_TYPE_ACTIVATE)
  		and Duel.IsChainNegatable(ev)
  		and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.cfilter2(c)
  	return c:IsRace(RACE_WARRIOR) and c:IsAbleToRemove()
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.cfilter3(c)
  	return c:IsFaceup() and c:IsRace(RACE_WARRIOR)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) or not Duel.IsExistingMatchingCard(s.cfilter3, tp, LOCATION_MZONE, 0, 1, nil) then
  		return
  	end
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  