name: Light
card_text: Cannot be Special Summoned. While face-up on the field, this card is also DARK-Attribute. Once per Chain, when a Spell/Trap Card, or monster effect, is activated (Quick Effect): This card loses exactly 500 ATK/DEF and that activation is negated. When this card is destroyed and sent to the GY: Target 1 monster in your GY (if possible); destroy all cards you control, also Special Summon that monster (if any).
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--Attribute Dark
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_ADD_ATTRIBUTE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(ATTRIBUTE_DARK)
  	c:RegisterEffect(e2)
  	--Negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_NEGATE)
  	e3:SetType(EFFECT_TYPE_QUICK_F)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.codisable)
  	e3:SetTarget(s.tgdisable)
  	e3:SetOperation(s.opdisable)
  	c:RegisterEffect(e3)
  	--Special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 4))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCondition(s.cdspsum)
  	e4:SetTarget(s.tgspsum)
  	e4:SetOperation(s.opspsum)
  	c:RegisterEffect(e4)
  end
  function s.codisable(e, tp, eg, ep, ev, re, r, rp)
  	return (re:IsHasType(EFFECT_TYPE_ACTIVATE) or re:IsActiveType(TYPE_MONSTER)) and not e:GetHandler():IsStatus(STATUS_CHAINING)
  end
  function s.tgdisable(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:GetFlagEffect(id) == 0
  	end
  	if c:IsHasEffect(EFFECT_REVERSE_UPDATE) then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.opdisable(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or c:GetDefense() < 500 or c:GetAttack() < 500 or not c:IsRelateToEffect(e) or Duel.GetCurrentChain() ~= ev + 1 or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return
  	end
  	if Duel.NegateActivation(ev) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-500)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		e2:SetValue(-500)
  		c:RegisterEffect(e2)
  	end
  end
  function s.cdspsum(e)
  	return e:GetHandler():IsReason(REASON_DESTROY)
  end
  function s.tgspsum(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and chkc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, Card.IsCanBeSpecialSummoned, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, 0, tp, false, false, POS_FACEUP, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, dg:GetCount(), 0, 0)
  end
  function s.opspsum(e, tp, eg, ep, ev, re, r, rp)
  	local dg = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.Destroy(dg, REASON_EFFECT)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Light
  Cannot be Special Summoned. While face-up on the field, this card is also DARK-Attribute. Once per Chain, when a Spell/Trap Card, or monster effect, is activated (Quick Effect): This card loses exactly 500 ATK/DEF and that activation is negated. When this card is destroyed and sent to the GY: Target 1 monster in your GY (if possible); destroy all cards you control, also Special Summon that monster (if any).
target_text: -- Light
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--Attribute Dark
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_ADD_ATTRIBUTE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(ATTRIBUTE_DARK)
  	c:RegisterEffect(e2)
  	--Negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_NEGATE)
  	e3:SetType(EFFECT_TYPE_QUICK_F)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.codisable)
  	e3:SetTarget(s.tgdisable)
  	e3:SetOperation(s.opdisable)
  	c:RegisterEffect(e3)
  	--Special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 4))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCondition(s.cdspsum)
  	e4:SetTarget(s.tgspsum)
  	e4:SetOperation(s.opspsum)
  	c:RegisterEffect(e4)
  end
  function s.codisable(e, tp, eg, ep, ev, re, r, rp)
  	return (re:IsHasType(EFFECT_TYPE_ACTIVATE) or re:IsActiveType(TYPE_MONSTER)) and not e:GetHandler():IsStatus(STATUS_CHAINING)
  end
  function s.tgdisable(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:GetFlagEffect(id) == 0
  	end
  	if c:IsHasEffect(EFFECT_REVERSE_UPDATE) then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.opdisable(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or c:GetDefense() < 500 or c:GetAttack() < 500 or not c:IsRelateToEffect(e) or Duel.GetCurrentChain() ~= ev + 1 or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return
  	end
  	if Duel.NegateActivation(ev) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-500)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e2:SetCode(EFFECT_UPDATE_DEFENSE)
  		e2:SetValue(-500)
  		c:RegisterEffect(e2)
  	end
  end
  function s.cdspsum(e)
  	return e:GetHandler():IsReason(REASON_DESTROY)
  end
  function s.tgspsum(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and chkc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, Card.IsCanBeSpecialSummoned, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, 0, tp, false, false, POS_FACEUP, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, dg:GetCount(), 0, 0)
  end
  function s.opspsum(e, tp, eg, ep, ev, re, r, rp)
  	local dg = Duel.GetMatchingGroup(nil, tp, LOCATION_ONFIELD, 0, nil)
  	Duel.Destroy(dg, REASON_EFFECT)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  