use data::{AvatarSkillData, ElementType};

pub struct Skill {
    skill_id: u32,
    slot: u32,
    // cd_start_time_ms: u64,
    // max_charge_count_delta: u32,
    // cd_time_delta: f32,
    // cd_time_ratio: f32,
    // cost_elem_delta: f32,
    // cost_elem_ratio: f32,
}

impl Skill {
    pub fn new(skill_id: u32) -> Self {
        Self { skill_id, slot: 0 }
    }

    pub fn get_config(&self) -> &'static AvatarSkillData {
        data::iter_avatar_skill_data()
            .find(|a| a.id == self.skill_id)
            .ok_or_else(|| panic!("find skill_id={} fails", self.skill_id))
            .unwrap()
    }

    pub fn get_max_elem_energy(&self) -> f32 {
        self.get_config().cost_elem_val
    }

    pub fn get_cost_elem_type(&self) -> ElementType {
        self.get_config().cost_elem_type
    }

    #[allow(dead_code)]
    pub fn get_skill_id(&self) -> u32 {
        self.skill_id
    }

    #[allow(dead_code)]
    pub fn get_slot(&self) -> u32 {
        self.slot
    }

    #[allow(dead_code)]
    pub fn set_slot(&mut self, slot: u32) {
        self.slot = slot;
    }
}
