Emperor
You can banish both 1 face-up Spellcaster-Type monster you control, except this card, and 1 "Spellbook" card from your Graveyard to target 1 face-up monster your opponent controls; take control of that target until the End Phase. You can only use the effect of "Emperor of Prophecy" once per turn. This card cannot attack during the turn you activate this effect.
local SETCARD_ID_0 = 0x106e --Spellbook

local SETCARD_ID_0 = 0x106e --Spellbook
local s, id, o = GetID()
function s.initial_effect(c)
	--attack up
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_CONTROL)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1, id)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.cfilter1(c, tp)
	return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) and c:IsAbleToRemoveAsCost() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
end
function s.cfilter2(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetAttackAnnouncedCount() == 0
			and Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_MZONE, 0, 1, e:GetHandler(), tp)
			and Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_GRAVE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g1 = Duel.SelectMatchingCard(tp, s.cfilter1, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler(), tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g2 = Duel.SelectMatchingCard(tp, s.cfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil)
	g1:Merge(g2)
	Duel.Remove(g1, POS_FACEUP, REASON_COST)
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.filter(c)
	return c:IsFaceup() and c:IsControlerCanBeChanged(true)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
		Duel.GetControl(tc, tp, PHASE_END, 1)
	end
end


Emperor
You can banish both 1 face-up Spellcaster-Type monster you control, except this card, and 1 "Spellbook" card from your Graveyard to target 1 face-up monster your opponent controls; take control of that target until the End Phase. You can only use the effect of "Emperor of Prophecy" once per turn. This card cannot attack during the turn you activate this effect.
-- Emperor
local SETCARD_ID_0 = 0x106e --Spellbook
local s, id, o = GetID()
function s.initial_effect(c)
	--attack up
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_CONTROL)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1, id)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.cfilter1(c, tp)
	return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) and c:IsAbleToRemoveAsCost() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
end
function s.cfilter2(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetAttackAnnouncedCount() == 0
			and Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_MZONE, 0, 1, e:GetHandler(), tp)
			and Duel.IsExistingMatchingCard(s.cfilter2, tp, LOCATION_GRAVE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g1 = Duel.SelectMatchingCard(tp, s.cfilter1, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler(), tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g2 = Duel.SelectMatchingCard(tp, s.cfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil)
	g1:Merge(g2)
	Duel.Remove(g1, POS_FACEUP, REASON_COST)
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_ATTACK)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
	e:GetHandler():RegisterEffect(e1)
end
function s.filter(c)
	return c:IsFaceup() and c:IsControlerCanBeChanged(true)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
		Duel.GetControl(tc, tp, PHASE_END, 1)
	end
end

