name: D.D.
card_text: There can only be 1 "D.D. Esper Star Sparrow" on the field. Your opponent cannot target other monsters you control with effects or for attacks. When an opponent's monster declares a direct attack while this card is in your Graveyard: You can Special Summon this card from your Graveyard in face-up Defense Position. If Summoned this way, banish it when it leaves the field.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, id)
  	--target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetValue(s.atlimit)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.atlimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():IsControler(1 - tp) and Duel.GetAttackTarget() == nil
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e1, true)
  	end
  end
  
  
source_text: D.D.
  There can only be 1 "D.D. Esper Star Sparrow" on the field. Your opponent cannot target other monsters you control with effects or for attacks. When an opponent's monster declares a direct attack while this card is in your Graveyard: You can Special Summon this card from your Graveyard in face-up Defense Position. If Summoned this way, banish it when it leaves the field.
target_text: -- D.D.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, id)
  	--target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetValue(s.atlimit)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.atlimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler()
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():IsControler(1 - tp) and Duel.GetAttackTarget() == nil
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e1, true)
  	end
  end
  
  