name: Obliterate!!!
card_text: You can target 1 monster on the field; send 1 "Forbidden One" monster or "Exodia" card from your hand or Deck to the Graveyard, and if you do, return that target to the hand. If this card is sent from the Spell & Trap Zone to the Graveyard: You can target 1 "Forbidden One" monster or "Exodia" card in your Graveyard; add it to your hand. You can only use 1 "Obliterate!!!" effect per turn, and only once that turn.
external_ids: local SETCARD_ID_0 = 0x40 --Forbidden
  
lua: local SETCARD_ID_0 = 0x40 --Forbidden
  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)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--tohand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.thcon)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xde)) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsAbleToHand()
  	end
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoGrave(g, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_GRAVE) then
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_SZONE)
  end
  function s.thfilter(c)
  	return ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xde)) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Obliterate!!!
  You can target 1 monster on the field; send 1 "Forbidden One" monster or "Exodia" card from your hand or Deck to the Graveyard, and if you do, return that target to the hand. If this card is sent from the Spell & Trap Zone to the Graveyard: You can target 1 "Forbidden One" monster or "Exodia" card in your Graveyard; add it to your hand. You can only use 1 "Obliterate!!!" effect per turn, and only once that turn.
target_text: -- Obliterate!!!
  local SETCARD_ID_0 = 0x40 --Forbidden
  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)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--tohand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.thcon)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xde)) and c:IsAbleToGrave()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsAbleToHand()
  	end
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoGrave(g, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_GRAVE) then
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_SZONE)
  end
  function s.thfilter(c)
  	return ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)) or c:IsSetCard(0xde)) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  