name: Chaos
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by banishing 1 LIGHT and 1 DARK monster from your GY. Once per turn: You can pay 1000 LP; send as many cards in both players' hands and on the field as possible to the GY, then inflict 300 damage to your opponent for each card sent to the opponent's GY by this effect. You cannot activate other cards or effects during the turn you activate this card's effect.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.sgcost)
  	e3:SetTarget(s.sgtg)
  	e3:SetOperation(s.sgop)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_CHAIN, aux.FALSE)
  end
  function s.spcostfilter(c)
  	return c:IsAbleToRemoveAsCost() and c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	if Duel.GetMZoneCount(tp) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_GRAVE, 0, nil)
  	return g:CheckSubGroup(aux.gfcheck, 2, 2, Card.IsAttribute, ATTRIBUTE_LIGHT, ATTRIBUTE_DARK)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, aux.gfcheck, true, 2, 2, Card.IsAttribute, ATTRIBUTE_LIGHT, ATTRIBUTE_DARK)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local sg = e:GetLabelObject()
  	Duel.Remove(sg, POS_FACEUP, REASON_SPSUMMON)
  	sg:DeleteGroup()
  end
  function s.sgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000) and Duel.GetCustomActivityCount(id, tp, ACTIVITY_CHAIN) == 0
  	end
  	Duel.PayLPCost(tp, 1000)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(aux.TRUE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.damfilter(c, p)
  	return c:GetOwner() == p and c:IsAbleToGrave()
  end
  function s.sgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetFieldGroup(tp, 0xe, 0xe)
  	local dc = g:FilterCount(s.damfilter, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, 1 - tp, dc * 300)
  end
  function s.sgfilter(c, p)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(p)
  end
  function s.sgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0xe, 0xe)
  	Duel.SendtoGrave(g, REASON_EFFECT)
  	local og = Duel.GetOperatedGroup()
  	local ct = og:FilterCount(s.sgfilter, nil, 1 - tp)
  	if ct > 0 then
  		Duel.BreakEffect()
  		Duel.Damage(1 - tp, ct * 300, REASON_EFFECT)
  	end
  end
  
  
source_text: Chaos
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by banishing 1 LIGHT and 1 DARK monster from your GY. Once per turn: You can pay 1000 LP; send as many cards in both players' hands and on the field as possible to the GY, then inflict 300 damage to your opponent for each card sent to the opponent's GY by this effect. You cannot activate other cards or effects during the turn you activate this card's effect.
target_text: -- Chaos
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOGRAVE + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCost(s.sgcost)
  	e3:SetTarget(s.sgtg)
  	e3:SetOperation(s.sgop)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_CHAIN, aux.FALSE)
  end
  function s.spcostfilter(c)
  	return c:IsAbleToRemoveAsCost() and c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	if Duel.GetMZoneCount(tp) <= 0 then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_GRAVE, 0, nil)
  	return g:CheckSubGroup(aux.gfcheck, 2, 2, Card.IsAttribute, ATTRIBUTE_LIGHT, ATTRIBUTE_DARK)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spcostfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:SelectSubGroup(tp, aux.gfcheck, true, 2, 2, Card.IsAttribute, ATTRIBUTE_LIGHT, ATTRIBUTE_DARK)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local sg = e:GetLabelObject()
  	Duel.Remove(sg, POS_FACEUP, REASON_SPSUMMON)
  	sg:DeleteGroup()
  end
  function s.sgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000) and Duel.GetCustomActivityCount(id, tp, ACTIVITY_CHAIN) == 0
  	end
  	Duel.PayLPCost(tp, 1000)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetTargetRange(1, 0)
  	e1:SetValue(aux.TRUE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.damfilter(c, p)
  	return c:GetOwner() == p and c:IsAbleToGrave()
  end
  function s.sgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetFieldGroup(tp, 0xe, 0xe)
  	local dc = g:FilterCount(s.damfilter, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, 1 - tp, dc * 300)
  end
  function s.sgfilter(c, p)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(p)
  end
  function s.sgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0xe, 0xe)
  	Duel.SendtoGrave(g, REASON_EFFECT)
  	local og = Duel.GetOperatedGroup()
  	local ct = og:FilterCount(s.sgfilter, nil, 1 - tp)
  	if ct > 0 then
  		Duel.BreakEffect()
  		Duel.Damage(1 - tp, ct * 300, REASON_EFFECT)
  	end
  end
  
  