name: D
card_text: During the Standby Phase: You can have all "HERO" monsters you control gain 400 ATK (even if this card leaves the field). If a Level 8 or higher "Destiny HERO" monster(s) or a "Destiny End Dragoon" is Special Summoned to your field (except during the Damage Step): You can banish 1 card from your opponent's hand (random), field, or GY. If this card in the Spell & Trap Zone is destroyed by card effect: You can add 1 "Destiny HERO" monster from your Deck to your hand. You can only use each effect of "D - Tactics" once per turn.
external_ids: local CARD_ID_0 = 76263644 --Destiny End Dragoon
  local SETCARD_ID_0 = 0xc008 --Destiny
  local SETCARD_ID_1 = 0x8 --HERO
  
lua: local CARD_ID_0 = 76263644 --Destiny End Dragoon
  local SETCARD_ID_0 = 0xc008 --Destiny
  local SETCARD_ID_1 = 0x8 --HERO
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.adtg)
  	e2:SetOperation(s.adop)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.rmcon)
  	e3:SetTarget(s.rmtg)
  	e3:SetOperation(s.rmop)
  	c:RegisterEffect(e3)
  	--to hand
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id + 2)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.adfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.adfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.adfilter, tp, LOCATION_MZONE, 0, nil)
  	local tc = g:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(400)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		tc = g:GetNext()
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsControler(tp) and (c:IsCode(CARD_ID_0) or c:IsLevelAbove(8) and c:IsSetCard(SETCARD_ID_1))
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, nil)
  	local g2 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, nil)
  	local opt = 0
  	if g1:GetCount() > 0 and g2:GetCount() > 0 then
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	elseif g1:GetCount() > 0 then
  		opt = 0
  	elseif g2:GetCount() > 0 then
  		opt = 1
  	else
  		return
  	end
  	local sg = nil
  	if opt == 0 then
  		sg = g1:RandomSelect(tp, 1)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		sg = g2:Select(tp, 1, 1, nil)
  	end
  	Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_SZONE)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) 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
  During the Standby Phase: You can have all "HERO" monsters you control gain 400 ATK (even if this card leaves the field). If a Level 8 or higher "Destiny HERO" monster(s) or a "Destiny End Dragoon" is Special Summoned to your field (except during the Damage Step): You can banish 1 card from your opponent's hand (random), field, or GY. If this card in the Spell & Trap Zone is destroyed by card effect: You can add 1 "Destiny HERO" monster from your Deck to your hand. You can only use each effect of "D - Tactics" once per turn.
target_text: -- D
  local CARD_ID_0 = 76263644 --Destiny End Dragoon
  local SETCARD_ID_0 = 0xc008 --Destiny
  local SETCARD_ID_1 = 0x8 --HERO
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.adtg)
  	e2:SetOperation(s.adop)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.rmcon)
  	e3:SetTarget(s.rmtg)
  	e3:SetOperation(s.rmop)
  	c:RegisterEffect(e3)
  	--to hand
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1, id + 2)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.adfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.adfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.adfilter, tp, LOCATION_MZONE, 0, nil)
  	local tc = g:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(400)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		tc = g:GetNext()
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsControler(tp) and (c:IsCode(CARD_ID_0) or c:IsLevelAbove(8) and c:IsSetCard(SETCARD_ID_1))
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 1 - tp, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, nil)
  	local g2 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE, nil)
  	local opt = 0
  	if g1:GetCount() > 0 and g2:GetCount() > 0 then
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	elseif g1:GetCount() > 0 then
  		opt = 0
  	elseif g2:GetCount() > 0 then
  		opt = 1
  	else
  		return
  	end
  	local sg = nil
  	if opt == 0 then
  		sg = g1:RandomSelect(tp, 1)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		sg = g2:Select(tp, 1, 1, nil)
  	end
  	Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_SZONE)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) 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
  
  