name: Libromancer
card_text: You can reveal 1 Ritual Monster in your hand: Special Summon this card from your hand. During your opponent's turn (Quick Effect): You can Ritual Summon 1 "Libromancer" Ritual Monster from your hand, by Tributing monsters from your hand or field whose total Levels equal or exceed its Level. You can only use each effect of "Libromancer Magigirl" once per turn.
external_ids: local SETCARD_ID_0 = 0x17c --Libromancer
  
lua: local SETCARD_ID_0 = 0x17c --Libromancer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--SP sum itself
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--Ritual sum
  	local e2 = aux.AddRitualProcGreater2(c, s.ritfilter, LOCATION_HAND, nil, nil, true)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.ritcond)
  	c:RegisterEffect(e2)
  end
  function s.ritcond(e, tp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.ritfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcostfilter(c)
  	return c:IsType(TYPE_RITUAL) and c:IsType(TYPE_MONSTER) and not c:IsPublic()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter, tp, LOCATION_HAND, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.spcostfilter, tp, LOCATION_HAND, 0, 1, 1, c)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  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.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Libromancer
  You can reveal 1 Ritual Monster in your hand: Special Summon this card from your hand. During your opponent's turn (Quick Effect): You can Ritual Summon 1 "Libromancer" Ritual Monster from your hand, by Tributing monsters from your hand or field whose total Levels equal or exceed its Level. You can only use each effect of "Libromancer Magigirl" once per turn.
target_text: -- Libromancer
  local SETCARD_ID_0 = 0x17c --Libromancer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--SP sum itself
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--Ritual sum
  	local e2 = aux.AddRitualProcGreater2(c, s.ritfilter, LOCATION_HAND, nil, nil, true)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.ritcond)
  	c:RegisterEffect(e2)
  end
  function s.ritcond(e, tp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.ritfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcostfilter(c)
  	return c:IsType(TYPE_RITUAL) and c:IsType(TYPE_MONSTER) and not c:IsPublic()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter, tp, LOCATION_HAND, 0, 1, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.spcostfilter, tp, LOCATION_HAND, 0, 1, 1, c)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  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.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  