name: Empress
card_text: 2 Level 5 Spellcaster-Type monsters
  This card gains 300 ATK for each Xyz Material attached to a monster you control. Once per turn: You can detach 1 Xyz Material from this card; shuffle your Deck, then excavate the top 5 cards of your Deck, destroy monsters on the field up to the number of "Spellbook" cards excavated, also, after that, place the excavated cards on the top of the Deck in any order.
external_ids: local SETCARD_ID_0 = 0x106e --Spellbook
  
lua: local SETCARD_ID_0 = 0x106e --Spellbook
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_SPELLCASTER), 5, 2)
  	c:EnableReviveLimit()
  	--atklimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--confiem
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.atkval(e, c)
  	return Duel.GetOverlayCount(c:GetControler(), 1, 0) * 300
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 5
  	end
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ShuffleDeck(tp)
  	Duel.BreakEffect()
  	Duel.ConfirmDecktop(tp, 5)
  	local g = Duel.GetDecktopGroup(tp, 5)
  	local ct = g:FilterCount(s.filter, nil)
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if ct > 0 and sg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local dg = sg:Select(tp, 1, ct, nil)
  		Duel.HintSelection(dg)
  		Duel.Destroy(dg, REASON_EFFECT)
  		Duel.BreakEffect()
  	end
  	Duel.SortDecktop(tp, tp, 5)
  end
  
  
source_text: Empress
  2 Level 5 Spellcaster-Type monsters
  This card gains 300 ATK for each Xyz Material attached to a monster you control. Once per turn: You can detach 1 Xyz Material from this card; shuffle your Deck, then excavate the top 5 cards of your Deck, destroy monsters on the field up to the number of "Spellbook" cards excavated, also, after that, place the excavated cards on the top of the Deck in any order.
target_text: -- Empress
  local SETCARD_ID_0 = 0x106e --Spellbook
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_SPELLCASTER), 5, 2)
  	c:EnableReviveLimit()
  	--atklimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(s.atkval)
  	c:RegisterEffect(e1)
  	--confiem
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.atkval(e, c)
  	return Duel.GetOverlayCount(c:GetControler(), 1, 0) * 300
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) >= 5
  	end
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ShuffleDeck(tp)
  	Duel.BreakEffect()
  	Duel.ConfirmDecktop(tp, 5)
  	local g = Duel.GetDecktopGroup(tp, 5)
  	local ct = g:FilterCount(s.filter, nil)
  	local sg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if ct > 0 and sg:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local dg = sg:Select(tp, 1, ct, nil)
  		Duel.HintSelection(dg)
  		Duel.Destroy(dg, REASON_EFFECT)
  		Duel.BreakEffect()
  	end
  	Duel.SortDecktop(tp, tp, 5)
  end
  
  