Removes derive-getters, as it was incredibly annoying in IDEs, and couldn't figure out borrow lifetimes.

This commit is contained in:
2022-06-06 14:43:41 +02:00
parent ce33ec0649
commit c27ea0ae1e
16 changed files with 395 additions and 57 deletions

View File

@@ -3,10 +3,9 @@ use crate::static_data::species_data::ability_index::AbilityIndex;
use crate::static_data::statistic_set::StatisticSet;
use crate::static_data::statistics::Statistic;
use crate::utils::random::Random;
use derive_getters::Getters;
use hashbrown::HashSet;
#[derive(Getters, Debug)]
#[derive(Debug)]
pub struct Form<'a> {
name: String,
height: f32,
@@ -47,6 +46,37 @@ impl<'a> Form<'a> {
}
}
pub fn name(&self) -> &str {
&self.name
}
pub fn height(&self) -> f32 {
self.height
}
pub fn weight(&self) -> f32 {
self.weight
}
pub fn base_experience(&self) -> u32 {
self.base_experience
}
pub fn types(&self) -> &Vec<u8> {
&self.types
}
pub fn base_stats(&self) -> StatisticSet<u16> {
self.base_stats
}
pub fn abilities(&self) -> &Vec<String> {
&self.abilities
}
pub fn hidden_abilities(&self) -> &Vec<String> {
&self.hidden_abilities
}
pub fn moves(&self) -> &LearnableMoves<'a> {
&self.moves
}
pub fn flags(&self) -> &HashSet<String> {
&self.flags
}
pub fn get_type(&self, index: usize) -> u8 {
self.types[index]
}

View File

@@ -1,8 +1,8 @@
// Required for standard pokemon functions, but somewhat controversial nowadays. Consider adding a feature
// that allows for a more progressive gender system for those that want it?
#[derive(Eq, PartialEq, Debug)]
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Gender {
Male,
Female,
Genderless,
Genderless = 0,
Male = 1,
Female = 2,
}

View File

@@ -1,10 +1,9 @@
use self::super::form::Form;
use crate::static_data::species_data::gender::Gender;
use crate::utils::random::Random;
use derive_getters::Getters;
use hashbrown::{HashMap, HashSet};
#[derive(Debug, Getters)]
#[derive(Debug)]
pub struct Species<'a> {
id: u16,
name: String,
@@ -37,6 +36,27 @@ impl<'a> Species<'a> {
flags,
}
}
pub fn id(&self) -> u16 {
self.id
}
pub fn name(&self) -> &str {
&self.name
}
pub fn gender_rate(&self) -> f32 {
self.gender_rate
}
pub fn growth_rate(&self) -> &str {
&self.growth_rate
}
pub fn capture_rate(&self) -> u8 {
self.capture_rate
}
pub fn forms(&self) -> &HashMap<String, Form<'a>> {
&self.forms
}
pub fn flags(&self) -> &HashSet<String> {
&self.flags
}
pub fn add_form(&mut self, id: String, form: Form<'a>) {
self.forms.insert(id, form);