First chunk of battling is now fully working, along with integration tests! 🎉
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-06-17 19:53:33 +02:00
parent 59cc150643
commit b6ddd1ee13
34 changed files with 1934 additions and 1293 deletions

View File

@@ -6,28 +6,28 @@ use hashbrown::{HashMap, HashSet};
use std::lazy::SyncLazy;
#[derive(Debug)]
pub struct Species<'a> {
pub struct Species {
id: u16,
name: StringKey,
gender_rate: f32,
growth_rate: StringKey,
capture_rate: u8,
forms: HashMap<StringKey, Form<'a>>,
forms: HashMap<StringKey, Form>,
flags: HashSet<StringKey>,
}
static DEFAULT_KEY: SyncLazy<StringKey> = SyncLazy::new(|| StringKey::new("default"));
impl<'a> Species<'a> {
impl Species {
pub fn new(
id: u16,
name: &StringKey,
gender_rate: f32,
growth_rate: &StringKey,
capture_rate: u8,
default_form: Form<'a>,
default_form: Form,
flags: HashSet<StringKey>,
) -> Species<'a> {
) -> Species {
let mut forms = HashMap::with_capacity(1);
forms.insert_unique_unchecked(DEFAULT_KEY.clone(), default_form);
Species {
@@ -55,14 +55,14 @@ impl<'a> Species<'a> {
pub fn capture_rate(&self) -> u8 {
self.capture_rate
}
pub fn forms(&self) -> &HashMap<StringKey, Form<'a>> {
pub fn forms(&self) -> &HashMap<StringKey, Form> {
&self.forms
}
pub fn flags(&self) -> &HashSet<StringKey> {
&self.flags
}
pub fn add_form(&mut self, id: StringKey, form: Form<'a>) {
pub fn add_form(&mut self, id: StringKey, form: Form) {
self.forms.insert(id, form);
}