name: Libromancer
card_text: When this card is activated: You can Set 1 "Libromancer" Spell/Trap directly from your Deck, except "Libromancer Origin Story". "Libromancer" Ritual Monsters you control gain ATK equal to their own Level x 100. If a Ritual Monster is Ritual Summoned to your field (except during the Damage Step): You can target 1 Spell/Trap your opponent controls; destroy it. You can only use this effect of "Libromancer Origin Story" once per turn. You can only activate 1 "Libromancer Origin Story" 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)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.setfilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.setfilter, tp, LOCATION_DECK, 0, nil)
  	if #g > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local sc = g:Select(tp, 1, 1, nil):GetFirst()
  		Duel.SSet(tp, sc)
  	end
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_RITUAL)
  end
  function s.atkval(e, c)
  	return c:GetLevel() * 100
  end
  function s.spfilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_RITUAL) and c:IsSummonType(SUMMON_TYPE_RITUAL) and c:IsControler(tp)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.spfilter, 1, nil, tp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp) and chkc:IsType(TYPE_SPELL + TYPE_TRAP)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsType, tp, 0, LOCATION_ONFIELD, 1, nil, TYPE_SPELL + TYPE_TRAP)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, Card.IsType, tp, 0, LOCATION_ONFIELD, 1, 1, nil, TYPE_SPELL + TYPE_TRAP)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Libromancer
  When this card is activated: You can Set 1 "Libromancer" Spell/Trap directly from your Deck, except "Libromancer Origin Story". "Libromancer" Ritual Monsters you control gain ATK equal to their own Level x 100. If a Ritual Monster is Ritual Summoned to your field (except during the Damage Step): You can target 1 Spell/Trap your opponent controls; destroy it. You can only use this effect of "Libromancer Origin Story" once per turn. You can only activate 1 "Libromancer Origin Story" per turn.
target_text: -- Libromancer
  local SETCARD_ID_0 = 0x17c --Libromancer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.setfilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.setfilter, tp, LOCATION_DECK, 0, nil)
  	if #g > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local sc = g:Select(tp, 1, 1, nil):GetFirst()
  		Duel.SSet(tp, sc)
  	end
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_RITUAL)
  end
  function s.atkval(e, c)
  	return c:GetLevel() * 100
  end
  function s.spfilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_RITUAL) and c:IsSummonType(SUMMON_TYPE_RITUAL) and c:IsControler(tp)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.spfilter, 1, nil, tp)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp) and chkc:IsType(TYPE_SPELL + TYPE_TRAP)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsType, tp, 0, LOCATION_ONFIELD, 1, nil, TYPE_SPELL + TYPE_TRAP)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, Card.IsType, tp, 0, LOCATION_ONFIELD, 1, 1, nil, TYPE_SPELL + TYPE_TRAP)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  