
-- 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

newTalent{
	name = "Heal",
	display_name ="治疗术",
	type = {"spell/aegis", 1},
	require = spells_req1,
	points = 5,
	mana = 25,
	cooldown = 16,
	tactical = { HEAL = 2 },
	getHeal = function(self, t) return 40 + self:combatTalentSpellDamage(t, 10, 520) end,
	is_heal = true,
	action = function(self, t)
		self:heal(self:spellCrit(t.getHeal(self, t)), self)
		game:playSoundNear(self, "talents/heal")
		return true
	end,
	info = function(self, t)
		local heal = t.getHeal(self, t)
		return ([[召唤自然的力量治疗你 %d 生命值。
		受法术强度影响，治疗量有额外加成。]]):
		format(heal)
	end,
}

newTalent{
	name = "Shielding",
	display_name ="强化护盾",
	type = {"spell/aegis", 2},
	require = spells_req2,
	points = 5,
	mode = "sustained",
	sustain_mana = 40,
	cooldown = 14,
	tactical = { BUFF = 2 },
	getDur = function(self, t) return math.ceil(2 + self:getTalentLevel(t) / 2) end,
	getShield = function(self, t) return 20 + self:combatTalentSpellDamage(t, 5, 400) / 10 end,
	activate = function(self, t)
		local dur = t.getDur(self, t)
		local shield = t.getShield(self, t)
		game:playSoundNear(self, "talents/arcane")
		local ret = {
			shield = self:addTemporaryValue("shield_factor", shield),
			dur = self:addTemporaryValue("shield_dur", dur),
		}
		self:checkEncumbrance()
		return ret
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("shield_factor", p.shield)
		self:removeTemporaryValue("shield_dur", p.dur)
		return true
	end,
	info = function(self, t)
		local shield = t.getShield(self, t)
		local dur = t.getDur(self, t)
		return ([[使你的周身围绕着强烈的奥术能量。
		每个伤害护盾，时间护盾或转移护盾的强度上升 %d%% ，持续时间增加 %d 回合。
		受法术强度影响，护盾韧性有额外加成。]]):
		format(shield, dur)
	end,
}

newTalent{
	name = "Arcane Shield",
	display_name ="奥术护盾",
	type = {"spell/aegis", 3},
	require = spells_req3,
	points = 5,
	mode = "sustained",
	sustain_mana = 50,
	cooldown = 30,
	tactical = { BUFF = 2 },
	getShield = function(self, t) return 20 + self:combatTalentSpellDamage(t, 5, 500) / 10 end,
	activate = function(self, t)
		local shield = t.getShield(self, t)
		game:playSoundNear(self, "talents/arcane")
		local ret = {
			shield = self:addTemporaryValue("arcane_shield", shield),
		}
		self:checkEncumbrance()
		return ret
	end,
	deactivate = function(self, t, p)
		self:removeTemporaryValue("arcane_shield", p.shield)
		return true
	end,
	info = function(self, t)
		local shield = t.getShield(self, t)
		return ([[使你的周身围绕着保护性的奥术能量。
		每当你获得一个直接治疗时（非持续恢复效果），你会自动获得一个护盾，护盾强度为治疗量的 %d%% ，持续3回合。
		受法术强度影响，护盾韧性有额外加成。]]):
		format(shield)
	end,
}

newTalent{
	name = "Aegis",
	display_name ="守护印记",
	type = {"spell/aegis", 4},
	require = spells_req4,
	points = 5,
	mana = 50,
	cooldown = 25,
	no_energy = true,
	tactical = { HEAL = 2 },
	getShield = function(self, t) return 40 + self:combatTalentSpellDamage(t, 5, 500) / 10 end,
	on_pre_use = function(self, t)
		for eff_id, p in pairs(self.tmp) do
			local e = self.tempeffect_def[eff_id]
			if e.on_aegis then return true end
		end
	end,
	action = function(self, t)
		local target = self
		local shield = t.getShield(self, t)
		local effs = {}

		-- Go through all spell effects
		for eff_id, p in pairs(target.tmp) do
			local e = target.tempeffect_def[eff_id]
			if e.on_aegis then
				effs[#effs+1] = {id=eff_id, e=e, p=p}
			end
		end

		for i = 1, self:getTalentLevelRaw(t) do
			if #effs == 0 then break end
			local eff = rng.tableRemove(effs)

			eff.e.on_aegis(self, eff.p, shield)
		end

		game:playSoundNear(self, "talents/heal")
		return true
	end,
	info = function(self, t)
		local shield = t.getShield(self, t)
		return ([[释放奥术能量充满当前保护你的魔法护盾，进一步强化它，提高 %d%% 伤害最大吸收值。
		它会影响最多 %d 种护盾效果。
		可被充能的护盾有：伤害类护盾，时间类护盾和转移类护盾。
		受法术强度影响，充能强度有额外加成。]]):
		format(shield, self:getTalentLevelRaw(t))
	end,
}
