-- 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 = "Thick Skin",
	display_name = "硬化皮肤",
	type = {"technique/combat-training", 1},
	mode = "passive",
	points = 5,
	require = { stat = { con=function(level) return 14 + level * 9 end }, },
	getRes = function(self, t) return 3 * self:getTalentLevelRaw(t) end,
	on_learn = function(self, t)
		self.resists.all = (self.resists.all or 0) + 3
	end,
	on_unlearn = function(self, t)
		self.resists.all = (self.resists.all or 0) - 3
	end,
	info = function(self, t)
		local res = t.getRes(self, t)
		return ([[你的皮肤变的更加坚硬。增加 %d%% 所有伤害抵抗。]]):
		format(res)
	end,
}

newTalent{
	name = "Armour Training",
	display_name = "护甲训练",
	type = {"technique/combat-training", 1},
	mode = "passive",
	points = 10,
	require = { stat = { str=function(level) return 18 + level - 1 end }, },
	on_unlearn = function(self, t)
		for inven_id, inven in pairs(self.inven) do if inven.worn then
			for i = #inven, 1, -1 do
				local o = inven[i]
				local ok, err = self:canWearObject(o)
				if not ok and err == "missing dependency" then
					game.logPlayer(self, "You can not use your %s anymore.", o:getName{do_color=true})
					local o = self:removeObject(inven, i, true)
					self:addObject(self.INVEN_INVEN, o)
					self:sortInven()
				end
			end
		end end
	end,
	getArmorHardiness = function(self, t) return self:getTalentLevel(t) * 5 end,
	getArmor = function(self, t) return self:getTalentLevel(t) * 1.4 end,
	getCriticalChanceReduction = function(self, t) return self:getTalentLevel(t) * 1.9 end,
	info = function(self, t)
		local hardiness = t.getArmorHardiness(self, t)
		local armor = t.getArmor(self, t)
		local criticalreduction = t.getCriticalChanceReduction(self, t)
		local classrestriction = ""
		if self.descriptor and self.descriptor.subclass == "Brawler" then
			classrestriction = "(Note that brawlers will be unable to perform many of their talents in massive armour.)"
		end
		if self:knowTalent(self.T_STEALTH) then
			classrestriction = "(Note that wearing mail or plate armour will interfere with stealth.)"
		end
		return ([[训练护甲的使用方法。当你装备一件重甲时提高 %d 护甲并减少 %d%% 被暴击几率。
		它也会提高 %d%%护甲强度。
		在等级1时，能使你装备金属手套、头盔和重靴。
		在等级2时，能使你装备锁甲。
		在等级3时，能使你装备盾牌。
		在等级4时，它能使你装备板甲。
		%s]]):
		format(armor, criticalreduction, hardiness, classrestriction)
	end,
}

newTalent{
	name = "Combat Accuracy", short_name = "WEAPON_COMBAT",
	display_name = "强化命中",
	type = {"technique/combat-training", 1},
	points = 10,
	require = { level=function(level) return (level - 1) * 2 end },
	mode = "passive",
	getAttack = function(self, t) return self:getTalentLevel(t) * 5 end,
	info = function(self, t)
		local attack = t.getAttack(self, t)
		return ([[增加你的徒手、近身和远程武器命中 %d 点。]]):
		format(attack)
	end,
}

newTalent{
	name = "Weapons Mastery",
	display_name = "武器掌握",
	type = {"technique/combat-training", 1},
	points = 10,
	require = { stat = { str=function(level) return 12 + level * 3 end }, },
	mode = "passive",
	getDamage = function(self, t) return self:getTalentLevel(t) * 5 end,
	getPercentInc = function(self, t) return math.sqrt(self:getTalentLevel(t) / 10) / 2 end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		local inc = t.getPercentInc(self, t)
		return ([[增加 %d 点物理强度。同时增加 %d%% 剑、斧、狼牙棒、匕首和特殊武器伤害。]]):
		format(damage, 100*inc)
	end,
}


newTalent{
	name = "Knife Mastery",
	display_name = "匕首掌握",
	type = {"technique/combat-training", 1},
	points = 10,
	require = { stat = { dex=function(level) return 10 + level * 3 end }, },
	mode = "passive",
	getDamage = function(self, t) return self:getTalentLevel(t) * 5 end,
	getPercentInc = function(self, t) return math.sqrt(self:getTalentLevel(t) / 10) / 2 end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		local inc = t.getPercentInc(self, t)
		return ([[增加 %d 点物理强度。同时增加 %d%% 匕首武器伤害。]]):
		format(damage, 100*inc)
	end,
}

newTalent{
	name = "Exotic Weapons Mastery",
	display_name = "特殊武器掌握",
	type = {"technique/combat-training", 1},
	hide = true,
	points = 10,
	require = { stat = { str=function(level) return 10 + level * 3 end, dex=function(level) return 10 + level * 3 end }, },
	mode = "passive",
	getDamage = function(self, t) return self:getTalentLevel(t) * 5 end,
	getPercentInc = function(self, t) return math.sqrt(self:getTalentLevel(t) / 10) / 2 end,
	info = function(self, t)
		local damage = t.getDamage(self, t)
		local inc = t.getPercentInc(self, t)
		return ([[增加物理强度 %d 。增加特殊武器 %d%% 伤害。]]):
		format(damage, 100*inc)
	end,
}
