name: Dark
card_text: During your Standby Phase, if this card is in Defense Position, put 1 counter on this card. You can remove from play a number of card(s) in your Graveyard equal to the number of counters on this card to destroy that many Spell or Trap Card(s) on the field. Then remove all counter(s) from this card.
external_ids: local COUNTER_ID_0 = 0x28 --Counter(Dark
  
lua: local COUNTER_ID_0 = 0x28 --Counter(Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x28)
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.addccon)
  	e1:SetTarget(s.addct)
  	e1:SetOperation(s.addc)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.addccon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp and e:GetHandler():IsDefensePos()
  end
  function s.addct(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0x28)
  end
  function s.addc(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_GRAVE, 0, ct, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToRemove, tp, LOCATION_GRAVE, 0, ct, ct, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.filter(chkc)
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, ct, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if g:FilterCount(Card.IsRelateToEffect, nil, e) == g:GetCount() then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, ct, REASON_EFFECT)
  end
  
  
source_text: Dark
  During your Standby Phase, if this card is in Defense Position, put 1 counter on this card. You can remove from play a number of card(s) in your Graveyard equal to the number of counters on this card to destroy that many Spell or Trap Card(s) on the field. Then remove all counter(s) from this card.
target_text: -- Dark
  local COUNTER_ID_0 = 0x28 --Counter(Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x28)
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.addccon)
  	e1:SetTarget(s.addct)
  	e1:SetOperation(s.addc)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.addccon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp and e:GetHandler():IsDefensePos()
  end
  function s.addct(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0x28)
  end
  function s.addc(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		e:GetHandler():AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_GRAVE, 0, ct, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, Card.IsAbleToRemove, tp, LOCATION_GRAVE, 0, ct, ct, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.filter(chkc)
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, ct, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if g:FilterCount(Card.IsRelateToEffect, nil, e) == g:GetCount() then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  	local ct = e:GetHandler():GetCounter(COUNTER_ID_0)
  	e:GetHandler():RemoveCounter(tp, COUNTER_ID_0, ct, REASON_EFFECT)
  end
  
  