name: U.A.
card_text: (This card is always treated as a "F.A." card.)
  When this card is activated: You can add 1 "U.A." or "F.A." monster from your Deck to your hand, OR add 1 "U.A. Stadium" from your GY to your hand. You can reveal 1 Field Spell in your hand and pay 1000 LP; you can Normal Summon 1 "U.A." or "F.A." monster during your Main Phase this turn, in addition to your Normal Summon/Set. (You can only gain this effect once per turn.) You can only activate 1 "U.A. Hyper Stadium" per turn.
external_ids: local CARD_ID_0 = 19814508 --U.A. Stadium
  local SETCARD_ID_0 = 0xb2 --U.A.
  
lua: local CARD_ID_0 = 19814508 --U.A. Stadium
  local SETCARD_ID_0 = 0xb2 --U.A.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_GRAVE_ACTION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--extra summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCost(s.excost)
  	e2:SetTarget(s.extg)
  	e2:SetOperation(s.exop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  end
  function s.thfilter(c)
  	if not c:IsAbleToHand() then
  		return false
  	end
  	return c:IsLocation(LOCATION_DECK) and c:IsSetCard(SETCARD_ID_0, 0x107) and c:IsType(TYPE_MONSTER) or c:IsLocation(LOCATION_GRAVE) and c:IsCode(CARD_ID_0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, nil)
  	local sel = 1
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 0))
  	if g:GetCount() > 0 then
  		sel = Duel.SelectOption(tp, 1213, 1214)
  	else
  		sel = Duel.SelectOption(tp, 1214) + 1
  	end
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_FIELD) and not c:IsPublic()
  end
  function s.excost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil) and Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  	Duel.PayLPCost(tp, 1000)
  end
  function s.extg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsPlayerCanSummon(tp) and Duel.IsPlayerCanAdditionalSummon(tp)
  	end
  end
  function s.exop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetTargetRange(LOCATION_HAND + LOCATION_MZONE, 0)
  	e1:SetCode(EFFECT_EXTRA_SUMMON_COUNT)
  	e1:SetTarget(s.estg)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.estg(e, c)
  	return c:IsSetCard(SETCARD_ID_0, 0x107)
  end
  
  
source_text: U.A.
  (This card is always treated as a "F.A." card.)
  When this card is activated: You can add 1 "U.A." or "F.A." monster from your Deck to your hand, OR add 1 "U.A. Stadium" from your GY to your hand. You can reveal 1 Field Spell in your hand and pay 1000 LP; you can Normal Summon 1 "U.A." or "F.A." monster during your Main Phase this turn, in addition to your Normal Summon/Set. (You can only gain this effect once per turn.) You can only activate 1 "U.A. Hyper Stadium" per turn.
target_text: -- U.A.
  local CARD_ID_0 = 19814508 --U.A. Stadium
  local SETCARD_ID_0 = 0xb2 --U.A.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_GRAVE_ACTION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--extra summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCost(s.excost)
  	e2:SetTarget(s.extg)
  	e2:SetOperation(s.exop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  end
  function s.thfilter(c)
  	if not c:IsAbleToHand() then
  		return false
  	end
  	return c:IsLocation(LOCATION_DECK) and c:IsSetCard(SETCARD_ID_0, 0x107) and c:IsType(TYPE_MONSTER) or c:IsLocation(LOCATION_GRAVE) and c:IsCode(CARD_ID_0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, nil)
  	local sel = 1
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 0))
  	if g:GetCount() > 0 then
  		sel = Duel.SelectOption(tp, 1213, 1214)
  	else
  		sel = Duel.SelectOption(tp, 1214) + 1
  	end
  	if sel == 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_FIELD) and not c:IsPublic()
  end
  function s.excost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil) and Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  	Duel.PayLPCost(tp, 1000)
  end
  function s.extg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0 and Duel.IsPlayerCanSummon(tp) and Duel.IsPlayerCanAdditionalSummon(tp)
  	end
  end
  function s.exop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetTargetRange(LOCATION_HAND + LOCATION_MZONE, 0)
  	e1:SetCode(EFFECT_EXTRA_SUMMON_COUNT)
  	e1:SetTarget(s.estg)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.estg(e, c)
  	return c:IsSetCard(SETCARD_ID_0, 0x107)
  end
  
  