Initial work on adding documentation, reorganises modules
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
77
src/static_data/items.rs
Normal file
77
src/static_data/items.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user