name: Dark
card_text: Cannot be Special Summoned. Negate any Spell effects that target a face-up DARK monster(s) you control, and if you do, destroy that Spell Card. During your Draw Phase, instead of conducting your normal draw: You can add 1 Level 4 DARK monster from your Deck to your hand. This card must be face-up on the field to activate and to resolve this effect.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--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)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_DISABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e2:SetTarget(s.distg)
  	c:RegisterEffect(e2)
  	--disable effect
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_CHAIN_SOLVING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e4:SetTarget(s.distg)
  	c:RegisterEffect(e4)
  	--search
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_PREDRAW)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCondition(s.condition)
  	e5:SetTarget(s.target)
  	e5:SetOperation(s.operation)
  	c:RegisterEffect(e5)
  end
  function s.distg(e, c)
  	if c:GetCardTargetCount() == 0 or not c:IsType(TYPE_SPELL) then
  		return false
  	end
  	return c:GetCardTarget():IsExists(s.disfilter, 1, nil, e:GetHandlerPlayer())
  end
  function s.disfilter(c, tp)
  	return c:IsControler(tp) and c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsActiveType(TYPE_SPELL) then
  		return
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() == 0 then
  		return
  	end
  	if g:IsExists(s.disfilter, 1, nil, tp) then
  		if Duel.NegateEffect(ev, true) and re:GetHandler():IsRelateToEffect(re) then
  			Duel.Destroy(re:GetHandler(), REASON_EFFECT)
  		end
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.filter(c)
  	return c:IsLevel(4) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return aux.IsPlayerCanNormalDraw(tp) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if not aux.IsPlayerCanNormalDraw(tp) then
  		return
  	end
  	aux.GiveUpNormalDraw(e, tp)
  	if not e:GetHandler():IsRelateToEffect(e) or e:GetHandler():IsFacedown() then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() ~= 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Dark
  Cannot be Special Summoned. Negate any Spell effects that target a face-up DARK monster(s) you control, and if you do, destroy that Spell Card. During your Draw Phase, instead of conducting your normal draw: You can add 1 Level 4 DARK monster from your Deck to your hand. This card must be face-up on the field to activate and to resolve this effect.
target_text: -- Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--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)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_DISABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e2:SetTarget(s.distg)
  	c:RegisterEffect(e2)
  	--disable effect
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_CHAIN_SOLVING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e4:SetTarget(s.distg)
  	c:RegisterEffect(e4)
  	--search
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_PREDRAW)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCondition(s.condition)
  	e5:SetTarget(s.target)
  	e5:SetOperation(s.operation)
  	c:RegisterEffect(e5)
  end
  function s.distg(e, c)
  	if c:GetCardTargetCount() == 0 or not c:IsType(TYPE_SPELL) then
  		return false
  	end
  	return c:GetCardTarget():IsExists(s.disfilter, 1, nil, e:GetHandlerPlayer())
  end
  function s.disfilter(c, tp)
  	return c:IsControler(tp) and c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsActiveType(TYPE_SPELL) then
  		return
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() == 0 then
  		return
  	end
  	if g:IsExists(s.disfilter, 1, nil, tp) then
  		if Duel.NegateEffect(ev, true) and re:GetHandler():IsRelateToEffect(re) then
  			Duel.Destroy(re:GetHandler(), REASON_EFFECT)
  		end
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.filter(c)
  	return c:IsLevel(4) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return aux.IsPlayerCanNormalDraw(tp) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, 0, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	if not aux.IsPlayerCanNormalDraw(tp) then
  		return
  	end
  	aux.GiveUpNormalDraw(e, tp)
  	if not e:GetHandler():IsRelateToEffect(e) or e:GetHandler():IsFacedown() then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() ~= 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  