name: D.D.
card_text: Monsters you control gain 300 ATK for each card type (Monster, Spell, or Trap) among your banished cards. Once per turn, during the Main Phase: You can banish 1 card from your hand or GY, then you can shuffle 1 of your banished cards into the Deck. If this card is banished: You can place it face-up on your field. You can only use this effect of "D.D. Post" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_REMOVE + CATEGORY_TODECK)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetHintTiming(0, TIMING_MAIN_END)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.rmcon)
  	e3:SetTarget(s.rmtg)
  	e3:SetOperation(s.rmop)
  	c:RegisterEffect(e3)
  	--set
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_REMOVE)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id)
  	e4:SetTarget(s.settg)
  	e4:SetOperation(s.setop)
  	c:RegisterEffect(e4)
  end
  function s.GetIntType(c)
  	if c:IsType(TYPE_MONSTER) then
  		return TYPE_MONSTER
  	elseif c:IsType(TYPE_SPELL) then
  		return TYPE_SPELL
  	elseif c:IsType(TYPE_TRAP) then
  		return TYPE_TRAP
  	end
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, e:GetHandlerPlayer(), LOCATION_REMOVED, 0, nil)
  	return g:GetClassCount(s.GetIntType) * 300
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsMainPhase()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(Card.IsAbleToRemove), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil)
  	if
  		g:GetCount() > 0
  		and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) > 0
  		and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, LOCATION_REMOVED, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 3))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local sg = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, LOCATION_REMOVED, 0, 1, 1, c)
  		if sg:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.HintSelection(sg)
  			Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		end
  	end
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and not c:IsForbidden() and c:CheckUniqueOnField(tp)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.MoveToField(c, tp, tp, LOCATION_SZONE, POS_FACEUP, true)
  	end
  end
  
  
source_text: D.D.
  Monsters you control gain 300 ATK for each card type (Monster, Spell, or Trap) among your banished cards. Once per turn, during the Main Phase: You can banish 1 card from your hand or GY, then you can shuffle 1 of your banished cards into the Deck. If this card is banished: You can place it face-up on your field. You can only use this effect of "D.D. Post" once per turn.
target_text: -- D.D.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_REMOVE + CATEGORY_TODECK)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetHintTiming(0, TIMING_MAIN_END)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.rmcon)
  	e3:SetTarget(s.rmtg)
  	e3:SetOperation(s.rmop)
  	c:RegisterEffect(e3)
  	--set
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_REMOVE)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id)
  	e4:SetTarget(s.settg)
  	e4:SetOperation(s.setop)
  	c:RegisterEffect(e4)
  end
  function s.GetIntType(c)
  	if c:IsType(TYPE_MONSTER) then
  		return TYPE_MONSTER
  	elseif c:IsType(TYPE_SPELL) then
  		return TYPE_SPELL
  	elseif c:IsType(TYPE_TRAP) then
  		return TYPE_TRAP
  	end
  end
  function s.atkval(e, c)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, e:GetHandlerPlayer(), LOCATION_REMOVED, 0, nil)
  	return g:GetClassCount(s.GetIntType) * 300
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsMainPhase()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(Card.IsAbleToRemove), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil)
  	if
  		g:GetCount() > 0
  		and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) > 0
  		and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, LOCATION_REMOVED, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 3))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local sg = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, LOCATION_REMOVED, 0, 1, 1, c)
  		if sg:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.HintSelection(sg)
  			Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		end
  	end
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and not c:IsForbidden() and c:CheckUniqueOnField(tp)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.MoveToField(c, tp, tp, LOCATION_SZONE, POS_FACEUP, true)
  	end
  end
  
  