name: D/D/D
card_text: Pendulum Scale = 1
  [ Pendulum Effect ]
  During your Main Phase: You can add 1 face-up "D/D/D" Pendulum Monster from your Extra Deck to your hand, except "D/D/D Destiny King Zero Laplace". You can only use this effect of "D/D/D Destiny King Zero Laplace" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  You can Special Summon this card (from your hand) by Tributing 1 "D/D/D" monster. Before damage calculation, if this card battles an opponent's monster: You can activate this effect; this card's ATK becomes double that opponent's monster's original ATK until the end of the Damage Step. If this card attacks a Defense Position monster, inflict piercing battle damage. The first time this card would be destroyed by battle each turn, it is not destroyed, and you take no battle damage from that battle.
external_ids: local SETCARD_ID_0 = 0x10af --D/D/D
  
lua: local SETCARD_ID_0 = 0x10af --D/D/D
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--special summon from hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.hspcon)
  	e2:SetTarget(s.hsptg)
  	e2:SetOperation(s.hspop)
  	c:RegisterEffect(e2)
  	--atk
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_TODECK)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_CONFIRM)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  	--pierce
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e4)
  	--battle indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e5:SetCountLimit(1)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(s.valcon)
  	c:RegisterEffect(e5)
  	--no damage
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e6:SetValue(s.damlimit)
  	c:RegisterEffect(e6)
  end
  function s.thfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and not c:IsCode(id) 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_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_EXTRA)
  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_EXTRA, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.hspfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.CheckReleaseGroupEx(tp, s.hspfilter, 1, REASON_SPSUMMON, false, nil, tp)
  end
  function s.hsptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.hspfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
  	if tc then
  		e:SetLabelObject(tc)
  		return true
  	else
  		return false
  	end
  end
  function s.hspop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return c:IsRelateToBattle() and bc and bc:IsFaceup() and bc:IsRelateToBattle() and bc:GetBaseAttack() * 2 ~= c:GetAttack()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if c:IsFaceup() and c:IsRelateToBattle() and bc:IsFaceup() and bc:IsRelateToBattle() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(bc:GetBaseAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_DAMAGE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.valcon(e, re, r, rp)
  	if bit.band(r, REASON_BATTLE) ~= 0 then
  		e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		return true
  	else
  		return false
  	end
  end
  function s.damlimit(e, c)
  	if e:GetHandler():GetFlagEffect(id) == 0 then
  		return 1
  	else
  		return 0
  	end
  end
  
  
source_text: D/D/D
  Pendulum Scale = 1
  [ Pendulum Effect ]
  During your Main Phase: You can add 1 face-up "D/D/D" Pendulum Monster from your Extra Deck to your hand, except "D/D/D Destiny King Zero Laplace". You can only use this effect of "D/D/D Destiny King Zero Laplace" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  You can Special Summon this card (from your hand) by Tributing 1 "D/D/D" monster. Before damage calculation, if this card battles an opponent's monster: You can activate this effect; this card's ATK becomes double that opponent's monster's original ATK until the end of the Damage Step. If this card attacks a Defense Position monster, inflict piercing battle damage. The first time this card would be destroyed by battle each turn, it is not destroyed, and you take no battle damage from that battle.
target_text: -- D/D/D
  local SETCARD_ID_0 = 0x10af --D/D/D
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--special summon from hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.hspcon)
  	e2:SetTarget(s.hsptg)
  	e2:SetOperation(s.hspop)
  	c:RegisterEffect(e2)
  	--atk
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_TODECK)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_CONFIRM)
  	e3:SetCondition(s.atkcon)
  	e3:SetOperation(s.atkop)
  	c:RegisterEffect(e3)
  	--pierce
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e4)
  	--battle indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e5:SetCountLimit(1)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(s.valcon)
  	c:RegisterEffect(e5)
  	--no damage
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e6:SetValue(s.damlimit)
  	c:RegisterEffect(e6)
  end
  function s.thfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and not c:IsCode(id) 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_EXTRA, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_EXTRA)
  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_EXTRA, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.hspfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.CheckReleaseGroupEx(tp, s.hspfilter, 1, REASON_SPSUMMON, false, nil, tp)
  end
  function s.hsptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON):Filter(s.hspfilter, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
  	if tc then
  		e:SetLabelObject(tc)
  		return true
  	else
  		return false
  	end
  end
  function s.hspop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Release(g, REASON_SPSUMMON)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return c:IsRelateToBattle() and bc and bc:IsFaceup() and bc:IsRelateToBattle() and bc:GetBaseAttack() * 2 ~= c:GetAttack()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if c:IsFaceup() and c:IsRelateToBattle() and bc:IsFaceup() and bc:IsRelateToBattle() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(bc:GetBaseAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_DAMAGE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.valcon(e, re, r, rp)
  	if bit.band(r, REASON_BATTLE) ~= 0 then
  		e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		return true
  	else
  		return false
  	end
  end
  function s.damlimit(e, c)
  	if e:GetHandler():GetFlagEffect(id) == 0 then
  		return 1
  	else
  		return 0
  	end
  end
  
  