name: Ultimate
card_text: (This card is always treated as an "Ursarctic" and "Drytron" card.)
  Cannot be Normal Summoned/Set. Must be Special Summoned by card effect. If you control an "Ursarctic" or "Drytron" monster, except "Ultimate Bright Knight Ursatron Alpha": You can Special Summon this card from your hand, then you can add 1 "Ursarctic" or "Drytron" Spell/Trap from your Deck to your hand. You can only use this effect of "Ultimate Bright Knight Ursatron Alpha" once per turn.
external_ids: local SETCARD_ID_0 = 0x163 --Ursarctic
  
lua: local SETCARD_ID_0 = 0x163 --Ursarctic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.splimit(e, se, sp, st)
  	return se:IsHasType(EFFECT_TYPE_ACTIONS)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x154) and not c:IsCode(id)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSetCard(SETCARD_ID_0, 0x154) and c:IsAbleToHand()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	if
  		c:IsRelateToEffect(e)
  		and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0
  		and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		Duel.BreakEffect()
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Ultimate
  (This card is always treated as an "Ursarctic" and "Drytron" card.)
  Cannot be Normal Summoned/Set. Must be Special Summoned by card effect. If you control an "Ursarctic" or "Drytron" monster, except "Ultimate Bright Knight Ursatron Alpha": You can Special Summon this card from your hand, then you can add 1 "Ursarctic" or "Drytron" Spell/Trap from your Deck to your hand. You can only use this effect of "Ultimate Bright Knight Ursatron Alpha" once per turn.
target_text: -- Ultimate
  local SETCARD_ID_0 = 0x163 --Ursarctic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.splimit(e, se, sp, st)
  	return se:IsHasType(EFFECT_TYPE_ACTIONS)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0, 0x154) and not c:IsCode(id)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSetCard(SETCARD_ID_0, 0x154) and c:IsAbleToHand()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	if
  		c:IsRelateToEffect(e)
  		and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0
  		and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		Duel.BreakEffect()
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  