name: Gunkan
card_text: If you control "Gunkan Suship Shari", you can Special Summon this card (from your hand). You can only Special Summon "Gunkan Suship Ikura" once per turn this way. During your Main Phase: You can excavate the top 3 cards from your Deck, and if you do, you can either add to your hand or Special Summon 1 excavated "Gunkan Suship Shari", also shuffle the rest into your Deck. You can only use this effect of "Gunkan Suship Ikura" once per turn.
external_ids: local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 63060238 --Elemental HERO Blazeman
  local CARD_ID_3 = 97148796 --Drytron Alpha Thuban
  
lua: local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 63060238 --Elemental HERO Blazeman
  local CARD_ID_3 = 97148796 --Drytron Alpha Thuban
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--to hand or special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetDecktopGroup(tp, 3)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 3
  			and (
  				g:IsExists(Card.IsAbleToHand, 1, nil)
  				or ft > 0 and Duel.IsPlayerCanSpecialSummon(tp) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_3)
  			)
  	end
  end
  function s.filter(c, e, tp, ft)
  	return c:IsCode(CARD_ID_0) and (c:IsAbleToHand() or ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetDecktopGroup(tp, 3)
  	if #g == 3 then
  		Duel.ConfirmDecktop(tp, 3)
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		local tg = g:Filter(s.filter, nil, e, tp, ft)
  		if #tg > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  			local sg = tg:Select(tp, 1, 1, nil)
  			local tc = sg:GetFirst()
  			if tc:IsAbleToHand() and (ft <= 0 or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) or Duel.SelectOption(tp, 1190, 1152) == 0) then
  				Duel.SendtoHand(tc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, tc)
  			else
  				Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  			end
  		end
  		Duel.ShuffleDeck(tp)
  	end
  end
  
  
source_text: Gunkan
  If you control "Gunkan Suship Shari", you can Special Summon this card (from your hand). You can only Special Summon "Gunkan Suship Ikura" once per turn this way. During your Main Phase: You can excavate the top 3 cards from your Deck, and if you do, you can either add to your hand or Special Summon 1 excavated "Gunkan Suship Shari", also shuffle the rest into your Deck. You can only use this effect of "Gunkan Suship Ikura" once per turn.
target_text: -- Gunkan
  local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 63060238 --Elemental HERO Blazeman
  local CARD_ID_3 = 97148796 --Drytron Alpha Thuban
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--to hand or special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetDecktopGroup(tp, 3)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 3
  			and (
  				g:IsExists(Card.IsAbleToHand, 1, nil)
  				or ft > 0 and Duel.IsPlayerCanSpecialSummon(tp) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_3)
  			)
  	end
  end
  function s.filter(c, e, tp, ft)
  	return c:IsCode(CARD_ID_0) and (c:IsAbleToHand() or ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetDecktopGroup(tp, 3)
  	if #g == 3 then
  		Duel.ConfirmDecktop(tp, 3)
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		local tg = g:Filter(s.filter, nil, e, tp, ft)
  		if #tg > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  			local sg = tg:Select(tp, 1, 1, nil)
  			local tc = sg:GetFirst()
  			if tc:IsAbleToHand() and (ft <= 0 or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) or Duel.SelectOption(tp, 1190, 1152) == 0) then
  				Duel.SendtoHand(tc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, tc)
  			else
  				Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  			end
  		end
  		Duel.ShuffleDeck(tp)
  	end
  end
  
  