Initial work on adding documentation, reorganises modules
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-19 21:34:08 +02:00
parent 715f16e2b8
commit 314e9dbe1a
49 changed files with 806 additions and 473 deletions

77
src/static_data/items.rs Normal file
View File

@@ -0,0 +1,77 @@
use hashbrown::HashSet;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::StringKey;
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(u8)]
pub enum ItemCategory {
MiscItem,
Pokeball,
Medicine,
Berry,
TMHM,
FormChanger,
KeyItem,
Mail,
}
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(u8)]
pub enum BattleItemCategory {
None,
Healing,
StatusHealing,
Pokeball,
MiscBattleItem,
}
#[derive(Debug)]
pub struct Item {
name: StringKey,
category: ItemCategory,
battle_category: BattleItemCategory,
price: i32,
flags: HashSet<StringKey>,
}
impl Item {
pub fn new(
name: &StringKey,
category: ItemCategory,
battle_category: BattleItemCategory,
price: i32,
flags: HashSet<StringKey>,
) -> Item {
Item {
name: name.clone(),
category,
battle_category,
price,
flags,
}
}
pub fn name(&self) -> &StringKey {
&self.name
}
pub fn category(&self) -> ItemCategory {
self.category
}
pub fn battle_category(&self) -> BattleItemCategory {
self.battle_category
}
pub fn price(&self) -> i32 {
self.price
}
pub fn flags(&self) -> &HashSet<StringKey> {
&self.flags
}
pub fn has_flag(&self, key: &StringKey) -> bool {
self.flags.contains(key)
}
}