name: Amazing
card_text: Pay 800 LP; apply this effect, depending whose turn it is.
  ● Your turn: Add 1 "Amazement" card from your Deck to your hand.
  ● Your opponent's turn: Set 1 "Attraction" Trap directly from your Deck. It can be activated this turn.
  You can only activate 1 "Amazing Time Ticket" per turn.
external_ids: local SETCARD_ID_0 = 0x15b --Amazement
  local SETCARD_ID_1 = 0x15c --Attraction
  
lua: local SETCARD_ID_0 = 0x15b --Amazement
  local SETCARD_ID_1 = 0x15c --Attraction
  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)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 800)
  	end
  	Duel.PayLPCost(tp, 800)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_TRAP) and c:IsSSetable()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if Duel.GetTurnPlayer() == tp then
  		if chk == 0 then
  			return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  		end
  		e:SetCategory(CATEGORY_SEARCH)
  		Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	else
  		if chk == 0 then
  			return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		end
  		e:SetCategory(0)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetTurnPlayer() == tp then
  		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
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc and Duel.SSet(tp, tc) ~= 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetDescription(aux.Stringid(id, 0))
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
  			e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Amazing
  Pay 800 LP; apply this effect, depending whose turn it is.
  ● Your turn: Add 1 "Amazement" card from your Deck to your hand.
  ● Your opponent's turn: Set 1 "Attraction" Trap directly from your Deck. It can be activated this turn.
  You can only activate 1 "Amazing Time Ticket" per turn.
target_text: -- Amazing
  local SETCARD_ID_0 = 0x15b --Amazement
  local SETCARD_ID_1 = 0x15c --Attraction
  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)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 800)
  	end
  	Duel.PayLPCost(tp, 800)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_TRAP) and c:IsSSetable()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if Duel.GetTurnPlayer() == tp then
  		if chk == 0 then
  			return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  		end
  		e:SetCategory(CATEGORY_SEARCH)
  		Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	else
  		if chk == 0 then
  			return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		end
  		e:SetCategory(0)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetTurnPlayer() == tp then
  		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
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc and Duel.SSet(tp, tc) ~= 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetDescription(aux.Stringid(id, 0))
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
  			e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  