Palace
All monsters you control gain ATK/DEF equal to the number of different Attributes in your GY x 200. Once per turn: You can add 1 "Elementsaber" monster from your Deck to your hand, but skip the Battle Phase of your next turn (even if this card leaves the field). Once per turn, if an "Elementsaber" monster in your hand or field would send a card(s) from the hand to the GY to activate an effect, you can send that many "Elementsaber" monster(s) from your Deck to the GY, instead.
local SETCARD_ID_0 = 0x400d --Elementsaber

local SETCARD_ID_0 = 0x400d --Elementsaber
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)
	c:RegisterEffect(e1)
	--boost
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetRange(LOCATION_FZONE)
	e2:SetTargetRange(LOCATION_MZONE, 0)
	e2:SetValue(s.atkval)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_UPDATE_DEFENSE)
	c:RegisterEffect(e3)
	--search
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
	e4:SetType(EFFECT_TYPE_IGNITION)
	e4:SetRange(LOCATION_FZONE)
	e4:SetCountLimit(1)
	e4:SetTarget(s.thtg)
	e4:SetOperation(s.thop)
	c:RegisterEffect(e4)
	--change cost
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetType(EFFECT_TYPE_FIELD)
	e5:SetCode(id)
	e5:SetRange(LOCATION_FZONE)
	e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e5:SetCountLimit(1)
	e5:SetTargetRange(1, 0)
	c:RegisterEffect(e5)
end
function s.atkval(e, c)
	return Duel.GetMatchingGroup(Card.IsType, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil, TYPE_MONSTER):GetClassCount(Card.GetAttribute) * 200
end
function s.thfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
	end
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
end
function s.thop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
	if g:GetCount() > 0 and Duel.SendtoHand(g, nil, REASON_EFFECT) ~= 0 then
		Duel.ConfirmCards(1 - tp, g)
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_FIELD)
		e1:SetCode(EFFECT_SKIP_BP)
		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
		e1:SetTargetRange(1, 0)
		if Duel.GetTurnPlayer() == tp then
			e1:SetLabel(Duel.GetTurnCount())
			e1:SetCondition(s.skipcon)
			e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
		else
			e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 1)
		end
		Duel.RegisterEffect(e1, tp)
	end
end
function s.skipcon(e)
	return Duel.GetTurnCount() ~= e:GetLabel()
end


Palace
All monsters you control gain ATK/DEF equal to the number of different Attributes in your GY x 200. Once per turn: You can add 1 "Elementsaber" monster from your Deck to your hand, but skip the Battle Phase of your next turn (even if this card leaves the field). Once per turn, if an "Elementsaber" monster in your hand or field would send a card(s) from the hand to the GY to activate an effect, you can send that many "Elementsaber" monster(s) from your Deck to the GY, instead.
-- Palace
local SETCARD_ID_0 = 0x400d --Elementsaber
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)
	c:RegisterEffect(e1)
	--boost
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetCode(EFFECT_UPDATE_ATTACK)
	e2:SetRange(LOCATION_FZONE)
	e2:SetTargetRange(LOCATION_MZONE, 0)
	e2:SetValue(s.atkval)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_UPDATE_DEFENSE)
	c:RegisterEffect(e3)
	--search
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
	e4:SetType(EFFECT_TYPE_IGNITION)
	e4:SetRange(LOCATION_FZONE)
	e4:SetCountLimit(1)
	e4:SetTarget(s.thtg)
	e4:SetOperation(s.thop)
	c:RegisterEffect(e4)
	--change cost
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetType(EFFECT_TYPE_FIELD)
	e5:SetCode(id)
	e5:SetRange(LOCATION_FZONE)
	e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e5:SetCountLimit(1)
	e5:SetTargetRange(1, 0)
	c:RegisterEffect(e5)
end
function s.atkval(e, c)
	return Duel.GetMatchingGroup(Card.IsType, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil, TYPE_MONSTER):GetClassCount(Card.GetAttribute) * 200
end
function s.thfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
	end
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
end
function s.thop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
	if g:GetCount() > 0 and Duel.SendtoHand(g, nil, REASON_EFFECT) ~= 0 then
		Duel.ConfirmCards(1 - tp, g)
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_FIELD)
		e1:SetCode(EFFECT_SKIP_BP)
		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
		e1:SetTargetRange(1, 0)
		if Duel.GetTurnPlayer() == tp then
			e1:SetLabel(Duel.GetTurnCount())
			e1:SetCondition(s.skipcon)
			e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
		else
			e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 1)
		end
		Duel.RegisterEffect(e1, tp)
	end
end
function s.skipcon(e)
	return Duel.GetTurnCount() ~= e:GetLabel()
end

