2021-01-30 21:29:59 +00:00
|
|
|
use super::item_category::{BattleItemCategory, ItemCategory};
|
2022-06-11 15:22:46 +00:00
|
|
|
use crate::StringKey;
|
2021-01-30 21:29:59 +00:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
2022-06-06 12:43:41 +00:00
|
|
|
#[derive(Debug)]
|
2021-01-30 21:29:59 +00:00
|
|
|
pub struct Item {
|
2022-06-11 15:22:46 +00:00
|
|
|
name: StringKey,
|
2021-01-30 21:29:59 +00:00
|
|
|
category: ItemCategory,
|
|
|
|
battle_category: BattleItemCategory,
|
|
|
|
price: i32,
|
2022-06-11 15:22:46 +00:00
|
|
|
flags: HashSet<StringKey>,
|
2021-01-30 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Item {
|
|
|
|
pub fn new(
|
2022-06-11 15:22:46 +00:00
|
|
|
name: &StringKey,
|
2021-01-30 21:29:59 +00:00
|
|
|
category: ItemCategory,
|
|
|
|
battle_category: BattleItemCategory,
|
|
|
|
price: i32,
|
2022-06-11 15:22:46 +00:00
|
|
|
flags: HashSet<StringKey>,
|
2021-01-30 21:29:59 +00:00
|
|
|
) -> Item {
|
|
|
|
Item {
|
2022-06-11 15:22:46 +00:00
|
|
|
name: name.clone(),
|
2021-01-30 21:29:59 +00:00
|
|
|
category,
|
|
|
|
battle_category,
|
|
|
|
price,
|
|
|
|
flags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 15:22:46 +00:00
|
|
|
pub fn name(&self) -> &StringKey {
|
2022-06-06 12:43:41 +00:00
|
|
|
&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
|
|
|
|
}
|
2022-06-11 15:22:46 +00:00
|
|
|
pub fn flags(&self) -> &HashSet<StringKey> {
|
2022-06-06 12:43:41 +00:00
|
|
|
&self.flags
|
|
|
|
}
|
|
|
|
|
2022-06-11 15:22:46 +00:00
|
|
|
pub fn has_flag(&self, key: &StringKey) -> bool {
|
2021-01-30 21:29:59 +00:00
|
|
|
self.flags.contains(key)
|
|
|
|
}
|
|
|
|
}
|