name: D/D/D
card_text: 2+ "D/D" monsters
  You can target 1 "D/D" or "Dark Contract" card you control; destroy it, also, during your Main Phase this turn, you can conduct 1 Pendulum Summon of a "D/D" monster(s) in addition to your Pendulum Summon. (You can only gain this effect once per turn.) When your opponent activates a monster effect in the hand (Quick Effect): You can banish 1 "D/D" monster and 1 "Dark Contract" card from your GY; negate the activation. You can only use this effect of "D/D/D Sky King Zeus Ragnarok" once per turn.
external_ids: local SETCARD_ID_0 = 0xaf --D/D
  local SETCARD_ID_1 = 0xae --Dark
  
lua: local SETCARD_ID_0 = 0xaf --D/D
  local SETCARD_ID_1 = 0xae --Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_1), 2)
  	c:EnableReviveLimit()
  	--second pendulum summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1, 0xae)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToChain() then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  	if Duel.GetFlagEffect(tp, id) == 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_EXTRA_PENDULUM_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetCountLimit(1, id + o)
  		e1:SetValue(s.pendvalue)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.pendvalue(e, c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return ep == 1 - tp and loc == LOCATION_HAND and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
  end
  function s.rmfilter(c)
  	return c:IsAbleToRemoveAsCost() and (c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) or c:IsSetCard(0xae))
  end
  function s.cfilter1(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.cfilter2(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToRemoveAsCost()
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	if chk == 0 then
  		return rg:CheckSubGroup(aux.gffcheck, 2, 2, s.cfilter1, nil, s.cfilter2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = rg:SelectSubGroup(tp, aux.gffcheck, false, 2, 2, s.cfilter1, nil, s.cfilter2, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateActivation(ev)
  end
  
  
source_text: D/D/D
  2+ "D/D" monsters
  You can target 1 "D/D" or "Dark Contract" card you control; destroy it, also, during your Main Phase this turn, you can conduct 1 Pendulum Summon of a "D/D" monster(s) in addition to your Pendulum Summon. (You can only gain this effect once per turn.) When your opponent activates a monster effect in the hand (Quick Effect): You can banish 1 "D/D" monster and 1 "Dark Contract" card from your GY; negate the activation. You can only use this effect of "D/D/D Sky King Zeus Ragnarok" once per turn.
target_text: -- D/D/D
  local SETCARD_ID_0 = 0xaf --D/D
  local SETCARD_ID_1 = 0xae --Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_1), 2)
  	c:EnableReviveLimit()
  	--second pendulum summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1, 0xae)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToChain() then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  	if Duel.GetFlagEffect(tp, id) == 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_EXTRA_PENDULUM_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetCountLimit(1, id + o)
  		e1:SetValue(s.pendvalue)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.pendvalue(e, c)
  	return c:IsSetCard(SETCARD_ID_1)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return ep == 1 - tp and loc == LOCATION_HAND and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
  end
  function s.rmfilter(c)
  	return c:IsAbleToRemoveAsCost() and (c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) or c:IsSetCard(0xae))
  end
  function s.cfilter1(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.cfilter2(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToRemoveAsCost()
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	if chk == 0 then
  		return rg:CheckSubGroup(aux.gffcheck, 2, 2, s.cfilter1, nil, s.cfilter2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = rg:SelectSubGroup(tp, aux.gffcheck, false, 2, 2, s.cfilter1, nil, s.cfilter2, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateActivation(ev)
  end
  
  