name: Satellarknight
card_text: If this card is Summoned: You can target 5 "tellarknight" monsters in your Graveyard; shuffle all 5 into the Deck, then draw 1 card. You can only use this effect of "Satellarknight Sirius" once per turn.
external_ids: local SETCARD_ID_0 = 0x9c --tellarknight
  
lua: local SETCARD_ID_0 = 0x9c --tellarknight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--todeck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	s.star_knight_summon_effect = e1
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc, exc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 5, exc)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 5, 5, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 5, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not tg or tg:FilterCount(Card.IsRelateToEffect, nil, e) ~= 5 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  		Duel.ShuffleDeck(tp)
  	end
  	local ct = g:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct == 5 then
  		Duel.BreakEffect()
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  end
  
  
source_text: Satellarknight
  If this card is Summoned: You can target 5 "tellarknight" monsters in your Graveyard; shuffle all 5 into the Deck, then draw 1 card. You can only use this effect of "Satellarknight Sirius" once per turn.
target_text: -- Satellarknight
  local SETCARD_ID_0 = 0x9c --tellarknight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--todeck
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	s.star_knight_summon_effect = e1
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc, exc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 5, exc)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 5, 5, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 5, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not tg or tg:FilterCount(Card.IsRelateToEffect, nil, e) ~= 5 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  		Duel.ShuffleDeck(tp)
  	end
  	local ct = g:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct == 5 then
  		Duel.BreakEffect()
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  end
  
  