-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org

local default_eyal_descriptors = function(add)
	local base = {

	race =
	{
		__ALL__ = "disallow",
		Human = "allow",
		Elf = "allow",
		Dwarf = "allow",
		Halfling = "allow",
		Yeek = "allow",
		Undead = "allow",
		Construct = "allow",
	},

	class =
	{
		__ALL__ = "disallow",
		Psionic = "allow",
		Warrior = "allow",
		Archer = "allow",
		Rogue = "allow",
		Mage = "allow",
		Celestial = "allow",
		Wilder = "allow",
		Corrupter = "allow",
		Afflicted = "allow",
		Chronomancer = "allow",
		Psionic = "allow",
--		Adventurer = "allow",
	},
	subclass =
	{
		-- Nobody should be a sun paladin & anorithil but humans & elves
		['Sun Paladin'] = "nolore",
		Anorithil = "nolore",
		-- Nobody should be an archmage but human, elves, halflings and undeads
		Archmage = "nolore",
	},
}
	if add then table.merge(base, add) end
	return base
end

-- Player worlds/campaigns
newBirthDescriptor{
	type = "world",
	name = "Maj'Eyal",
	display_name = "Maj'Eyal: 优越的时代",
	font={"/data/font/tome.ttf", 16},
	desc =
	{
		"    Maj'Eyal的人：人类、半身人 、精灵和矮人再次繁荣起来，世界 已经保持了超过一百年的和平。",
		"    你是一位冒险者，出发去寻找 失落的宝藏和荣耀。在世界的阴影 之下究竟潜伏着什么呢？",
	},
	descriptor_choices = default_eyal_descriptors{},
	copy = {
		__allow_rod_recall = true,
		__allow_transmo_chest = true,
	}
}

newBirthDescriptor{
	type = "world",
	name = "Infinite",
	display_name = "无尽地城模式",
	locked = function() return profile.mod.allow_build.campaign_infinite_dungeon end,
	locked_desc = "    无尽深度，没有终点，没有重 复，不断深入，在古老的废墟里， 穿过关闭的大门，解开谜题，寻找 你的宿命。",
	desc =
	{
		"    选择你最喜欢的种族和职业， 进入无尽地城冒险。",
		"    能够前进多远取决于你的个人 技术！",
		"    在无尽地城中你不受限制，你 可以突破50级的等级上限并继续获 得属性和天赋点数（以一个较低的 比例获得）。",
		"    50级之后属性最大值每级增加 1点。",
		"    50级之后每10级每个天赋的最 大等级增加1点。",
	},
	descriptor_choices = default_eyal_descriptors{ difficulty = { Tutorial = "never"} },
	copy = {
		__allow_transmo_chest = true,

		-- Can levelup forever
		resolvers.generic(function(e) e.max_level = nil end),
		no_points_on_levelup = function(self)
			if self.level <= 50 then
				self.unused_stats = self.unused_stats + (self.stats_per_level or 3) + self:getRankStatAdjust()
				self.unused_talents = self.unused_talents + 1
				self.unused_generics = self.unused_generics + 1
				if self.level % 5 == 0 then self.unused_talents = self.unused_talents + 1 end
				if self.level % 5 == 0 then self.unused_generics = self.unused_generics - 1 end
				if self.level == 10 or  self.level == 20 or self.level == 30 or self.level == 40 then
					self.unused_talents_types = self.unused_talents_types + 1
				end
			else
				self.unused_stats = self.unused_stats + 1
				if self.level % 2 == 0 then
					self.unused_talents = self.unused_talents + 1
				elseif self.level % 3 == 0 then
					self.unused_generics = self.unused_generics + 1
				end
			end
		end,

		-- Give the orb of knowledge
		resolvers.inventory{ id=true, {defined="ORB_KNOWLEDGE"}},
		resolvers.equip{ id=true, {name="iron pickaxe", ego_chance=-1000}},
		resolvers.generic(function(e) e.hotkey[12] = {"inventory", "Orb of Knowledge"} end),
		-- Override normal stuff
		before_starting_zone = function(self)
			self.starting_level = 1
			self.starting_level_force_down = nil
			self.starting_zone = "infinite-dungeon"
			self.starting_quest = "infinite-dungeon"
			self.starting_intro = "infinite-dungeon"
		end,
	},
}

newBirthDescriptor{
	type = "world",
	name = "Arena",
	display_name = "竞技场：挑战BOSS",
	locked = function() return profile.mod.allow_build.campaign_arena end,
	locked_desc = "    血溅沙场，勇者生存，证明你 有进入的实力。",
	desc =
	{
		"    孤身一人直面竞技场的挑战！",
		"    你可以使用任何职业和种族。",
		"    看看你能前进多远！你能成为 新的竞技场冠军么？",
		"    如果这样，下一场战斗你的对 手就是你自己的冠军角色！",
	},
	descriptor_choices = default_eyal_descriptors{ difficulty = { Tutorial = "never" }, permadeath = { Exploration = "never", Adventure = "never" } },
	copy = {
		death_dialog = "ArenaFinish",
		-- Override normal stuff
		before_starting_zone = function(self)
			self.starting_level = 1
			self.starting_level_force_down = nil
			self.starting_zone = "arena"
			self.starting_quest = "arena"
			self.starting_intro = "arena"
		end,
	},
}

newBirthDescriptor{
	type = "world",
	name = "Spydre",
	display_name = "Spydrë: Thouch of the Spider",
	locked = function() return profile.mod.allow_build.campaign_spidre and true or "hide" end,
	locked_desc = "",
	desc =
	{
		"Spydrë is home to the essence of spiders. The mighty Ungoliant of Arda actually originated from this world.",
		"It is home to uncounted numbers of spider races, all fighting for supremacy of all the lands.",
		"Some humanoids also live there, but they are usually the prey, not the hunter.",
	},
	descriptor_choices =
	{
		race =
		{
			__ALL__ = "disallow",
			Human = "allow",
--			Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end,
		},
	},
}

newBirthDescriptor{
	type = "world",
	name = "Trolls",
	display_name = "Trolls: Pirates of the Kar'Haib",
	locked = function() return profile.mod.allow_build.campaign_troll and true or "hide" end,
	locked_desc = "",
	desc =
	{
		"",
	},
	descriptor_choices =
	{
		race =
		{
			__ALL__ = "disallow",
			Human = "allow",
--			Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end,
		},
	},
}

newBirthDescriptor{
	type = "world",
	name = "Nagas",
	display_name = "Nagas: Guardians of the Tide",
	locked = function() return profile.mod.allow_build.campaign_naga and true or "hide" end,
	locked_desc = "",
	desc =
	{
		"",
	},
	descriptor_choices =
	{
		race =
		{
			__ALL__ = "disallow",
			Human = "allow",
--			Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end,
		},
	},
}

newBirthDescriptor{
	type = "world",
	name = "Faeros",
	display_name = "Urthalath: Treason or the High Guards",
	locked = function() return profile.mod.allow_build.campaign_faeros and true or "hide" end,
	locked_desc = "",
	desc =
	{
		"",
	},
	descriptor_choices =
	{
		race =
		{
			__ALL__ = "disallow",
			Human = "allow",
--			Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end,
		},
	},
}

newBirthDescriptor{
	type = "world",
	name = "Undeads",
	display_name = "Broken Oath: The Curse of Undeath",
	locked = function() return profile.mod.allow_build.campaign_undead and true or "hide" end,
	locked_desc = "",
	desc =
	{
		"",
	},
	descriptor_choices =
	{
		race =
		{
			__ALL__ = "disallow",
			Human = "allow",
--			Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end,
		},
	},
}
