name: Chaos
card_text: 1 Tuner + 1+ non-Tuner LIGHT or DARK monsters
  For this card's Synchro Summon, you can treat 1 LIGHT or DARK monster you control as a Tuner. If this card is Special Summoned: You can target 1 card on the field; banish it. This card gains these effects based on the original Attributes of materials used for its Synchro Summon.
  ● LIGHT: Synchro Monsters you control are unaffected by monster effects activated by your opponent.
  ● DARK: Monsters you control cannot be destroyed by battle.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	c:EnableReviveLimit()
  	aux.AddSynchroMixProcedure(c, s.matfilter1, nil, nil, s.matfilter2, 1, 99)
  	--remove
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	--mat check
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	c:RegisterEffect(e2)
  	--synchro success
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCondition(s.regcon)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  	e3:SetLabelObject(e2)
  end
  function s.matfilter1(c, syncard)
  	return c:IsTuner(syncard) or c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.matfilter2(c, syncard)
  	return c:IsNotTuner(syncard) and c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsAbleToRemove()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToRemove, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToRemove, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local att = 0
  	local tc = g:GetFirst()
  	while tc do
  		att = bit.bor(att, tc:GetOriginalAttribute())
  		tc = g:GetNext()
  	end
  	e:SetLabel(att)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO) and e:GetLabelObject():GetLabel() ~= 0
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local att = e:GetLabelObject():GetLabel()
  	local c = e:GetHandler()
  	if bit.band(att, ATTRIBUTE_LIGHT) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_IMMUNE_EFFECT)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetTarget(aux.TargetBoolFunction(Card.IsType, TYPE_SYNCHRO))
  		e1:SetValue(s.efilter)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  		Duel.AdjustInstantly(c)
  		c:RegisterFlagEffect(0, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 0))
  	end
  	if bit.band(att, ATTRIBUTE_DARK) ~= 0 then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetTargetRange(LOCATION_MZONE, 0)
  		e2:SetValue(1)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e2)
  		Duel.AdjustInstantly(c)
  		c:RegisterFlagEffect(0, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 1))
  	end
  end
  function s.efilter(e, re)
  	return re:GetOwnerPlayer() ~= e:GetHandlerPlayer() and re:IsActivated() and re:IsActiveType(TYPE_MONSTER)
  end
  
  
source_text: Chaos
  1 Tuner + 1+ non-Tuner LIGHT or DARK monsters
  For this card's Synchro Summon, you can treat 1 LIGHT or DARK monster you control as a Tuner. If this card is Special Summoned: You can target 1 card on the field; banish it. This card gains these effects based on the original Attributes of materials used for its Synchro Summon.
  ● LIGHT: Synchro Monsters you control are unaffected by monster effects activated by your opponent.
  ● DARK: Monsters you control cannot be destroyed by battle.
target_text: -- Chaos
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	c:EnableReviveLimit()
  	aux.AddSynchroMixProcedure(c, s.matfilter1, nil, nil, s.matfilter2, 1, 99)
  	--remove
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.rmtg)
  	e1:SetOperation(s.rmop)
  	c:RegisterEffect(e1)
  	--mat check
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	c:RegisterEffect(e2)
  	--synchro success
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCondition(s.regcon)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  	e3:SetLabelObject(e2)
  end
  function s.matfilter1(c, syncard)
  	return c:IsTuner(syncard) or c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.matfilter2(c, syncard)
  	return c:IsNotTuner(syncard) and c:IsAttribute(ATTRIBUTE_LIGHT + ATTRIBUTE_DARK)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsAbleToRemove()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsAbleToRemove, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToRemove, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local att = 0
  	local tc = g:GetFirst()
  	while tc do
  		att = bit.bor(att, tc:GetOriginalAttribute())
  		tc = g:GetNext()
  	end
  	e:SetLabel(att)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO) and e:GetLabelObject():GetLabel() ~= 0
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local att = e:GetLabelObject():GetLabel()
  	local c = e:GetHandler()
  	if bit.band(att, ATTRIBUTE_LIGHT) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_IMMUNE_EFFECT)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetTarget(aux.TargetBoolFunction(Card.IsType, TYPE_SYNCHRO))
  		e1:SetValue(s.efilter)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  		Duel.AdjustInstantly(c)
  		c:RegisterFlagEffect(0, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 0))
  	end
  	if bit.band(att, ATTRIBUTE_DARK) ~= 0 then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetTargetRange(LOCATION_MZONE, 0)
  		e2:SetValue(1)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e2)
  		Duel.AdjustInstantly(c)
  		c:RegisterFlagEffect(0, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 1))
  	end
  end
  function s.efilter(e, re)
  	return re:GetOwnerPlayer() ~= e:GetHandlerPlayer() and re:IsActivated() and re:IsActiveType(TYPE_MONSTER)
  end
  
  