name: Sakitama
card_text: Cannot be Special Summoned. Once per turn, during the End Phase, if this card was Normal Summoned or flipped face-up this turn: Return this card to the hand. You can only use each of the following effects of "Sakitama" once per turn. You can reveal this card in your hand; immediately after this effect resolves, Normal Summon 1 Spirit monster from your hand. If this card is Tributed: Target 1 Spirit monster in your GY; add it to your hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.sumcost)
  	e2:SetTarget(s.sumtg)
  	e2:SetOperation(s.sumop)
  	c:RegisterEffect(e2)
  	--spirit return
  	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_RELEASE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.sumcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsPublic()
  	end
  end
  function s.sumfilter(c)
  	return c:IsType(TYPE_SPIRIT) and c:IsSummonable(true, nil)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.Summon(tp, tc, true, nil)
  	end
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_SPIRIT) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Sakitama
  Cannot be Special Summoned. Once per turn, during the End Phase, if this card was Normal Summoned or flipped face-up this turn: Return this card to the hand. You can only use each of the following effects of "Sakitama" once per turn. You can reveal this card in your hand; immediately after this effect resolves, Normal Summon 1 Spirit monster from your hand. If this card is Tributed: Target 1 Spirit monster in your GY; add it to your hand.
target_text: -- Sakitama
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.FALSE)
  	c:RegisterEffect(e1)
  	--summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.sumcost)
  	e2:SetTarget(s.sumtg)
  	e2:SetOperation(s.sumop)
  	c:RegisterEffect(e2)
  	--spirit return
  	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
  	--to hand
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOHAND)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_RELEASE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetTarget(s.thtg)
  	e3:SetOperation(s.thop)
  	c:RegisterEffect(e3)
  end
  function s.sumcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsPublic()
  	end
  end
  function s.sumfilter(c)
  	return c:IsType(TYPE_SPIRIT) and c:IsSummonable(true, nil)
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sumfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.sumfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.Summon(tp, tc, true, nil)
  	end
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_SPIRIT) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  