use std::ops::Deref;

use serde::Deserialize;

use super::ABILITIES_PATH;

#[derive(Debug, Deserialize)]
pub struct Abilities {
	pub abilities: Vec<Ability>,
}

impl Abilities {
	pub fn new() -> Abilities {
		let abilities_str = std::fs::read_to_string(ABILITIES_PATH).unwrap();
		toml::from_str::<Abilities>(&abilities_str).unwrap()
	}
}

impl Deref for Abilities {
	type Target = Vec<Ability>;

	fn deref(&self) -> &Self::Target {
		&self.abilities
	}
}

#[derive(Debug, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Ability {
	pub name: String,
	pub from: String,
	pub category: String,
	pub max: u8,
	pub types: Vec<char>,
}
