Added function to get the max amount of skill points that can be spent in a tree.

This commit is contained in:
Sam 2021-01-04 12:53:27 -05:00
parent b6d2d48ead
commit 1d90b64898

View File

@ -223,6 +223,24 @@ pub enum SkillGroupType {
impl SkillGroupType {
/// Gets the cost in experience of earning a skill point
pub fn skill_point_cost(self) -> u16 { 300 }
/// Gets the total amount of skill points that can be spent in a particular
/// skill group
pub fn get_max_skill_points(self) -> u16 {
let mut cost = 0;
if let Some(skill_list) = SKILL_GROUP_DEFS.get(&self) {
for skill in skill_list {
if let Some(max_level) = skill.get_max_level() {
for level in 1..=max_level {
cost += skill.skill_cost(Some(level));
}
} else {
cost += skill.skill_cost(None);
}
}
}
cost
}
}
/// A group of skills that have been unlocked by a player. Each skill group has