name: D/D/D
card_text: 2 Level 6 Fiend monsters
  When a Spell/Trap Card, or monster effect, is activated that includes an effect that Special Summons a monster(s) (Quick Effect): You can detach 1 material from this card; negate the activation, and if you do, destroy that card, then you can make 1 other "D/D" monster you control and this card gain 1800 ATK until the end of this turn. If this card is sent from the field to the GY: You can add 1 "Dark Contract" card from your Deck to your hand.
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)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_FIEND), 6, 2)
  	--Negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.discon)
  	e1:SetCost(s.discost)
  	e1:SetTarget(s.distg)
  	e1:SetOperation(s.disop)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) or not Duel.IsChainNegatable(ev) then
  		return false
  	end
  	if not re:IsActiveType(TYPE_MONSTER) and not re:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	return re:IsHasCategory(CATEGORY_SPECIAL_SUMMON)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.distg(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)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if
  		Duel.NegateActivation(ev)
  		and re:GetHandler():IsRelateToEffect(re)
  		and Duel.Destroy(eg, REASON_EFFECT) ~= 0
  		and c:IsRelateToEffect(e)
  		and c:IsFaceup()
  		and Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, c)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		local g = Duel.SelectMatchingCard(tp, s.atkfilter, tp, LOCATION_MZONE, 0, 1, 1, c)
  		local tc = g:GetFirst()
  		Duel.HintSelection(g)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(1800)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		tc:RegisterEffect(e2)
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, 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: D/D/D
  2 Level 6 Fiend monsters
  When a Spell/Trap Card, or monster effect, is activated that includes an effect that Special Summons a monster(s) (Quick Effect): You can detach 1 material from this card; negate the activation, and if you do, destroy that card, then you can make 1 other "D/D" monster you control and this card gain 1800 ATK until the end of this turn. If this card is sent from the field to the GY: You can add 1 "Dark Contract" card from your Deck to your hand.
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)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_FIEND), 6, 2)
  	--Negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.discon)
  	e1:SetCost(s.discost)
  	e1:SetTarget(s.distg)
  	e1:SetOperation(s.disop)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) or not Duel.IsChainNegatable(ev) then
  		return false
  	end
  	if not re:IsActiveType(TYPE_MONSTER) and not re:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return false
  	end
  	return re:IsHasCategory(CATEGORY_SPECIAL_SUMMON)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.distg(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)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if
  		Duel.NegateActivation(ev)
  		and re:GetHandler():IsRelateToEffect(re)
  		and Duel.Destroy(eg, REASON_EFFECT) ~= 0
  		and c:IsRelateToEffect(e)
  		and c:IsFaceup()
  		and Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, c)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  		local g = Duel.SelectMatchingCard(tp, s.atkfilter, tp, LOCATION_MZONE, 0, 1, 1, c)
  		local tc = g:GetFirst()
  		Duel.HintSelection(g)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(1800)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		tc:RegisterEffect(e2)
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, 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
  
  