name: Outstanding
card_text: If this card is sent to the GY: You can activate 1 of these effects;
  ● Place this card on the bottom of your Deck.
  ● Add 1 "Outstanding Dog Marron" from your Deck to your hand, and if you do, place this card on top of your Deck.
  You can only use this effect of "Outstanding Dog Mary" once per turn.
external_ids: local CARD_ID_0 = 11548522 --Outstanding Dog Marron
  
lua: local CARD_ID_0 = 11548522 --Outstanding Dog Marron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--effect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local b1 = c:IsAbleToDeck()
  	local b2 = Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and c:IsAbleToDeck()
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 2)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_TODECK)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, c, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_TODECK)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, c, 1, 0, 0)
  		Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if e:GetLabel() == 0 then
  		Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  	else
  		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 and Duel.SendtoHand(g, nil, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_HAND) then
  			Duel.ConfirmCards(1 - tp, g)
  			Duel.ShuffleDeck(tp)
  			Duel.SendtoDeck(c, nil, SEQ_DECKTOP, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Outstanding
  If this card is sent to the GY: You can activate 1 of these effects;
  ● Place this card on the bottom of your Deck.
  ● Add 1 "Outstanding Dog Marron" from your Deck to your hand, and if you do, place this card on top of your Deck.
  You can only use this effect of "Outstanding Dog Mary" once per turn.
target_text: -- Outstanding
  local CARD_ID_0 = 11548522 --Outstanding Dog Marron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--effect
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local b1 = c:IsAbleToDeck()
  	local b2 = Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil) and c:IsAbleToDeck()
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 2)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_TODECK)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, c, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_TODECK)
  		Duel.SetOperationInfo(0, CATEGORY_TODECK, c, 1, 0, 0)
  		Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if e:GetLabel() == 0 then
  		Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  	else
  		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 and Duel.SendtoHand(g, nil, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_HAND) then
  			Duel.ConfirmCards(1 - tp, g)
  			Duel.ShuffleDeck(tp)
  			Duel.SendtoDeck(c, nil, SEQ_DECKTOP, REASON_EFFECT)
  		end
  	end
  end
  
  