50 lines
1.0 KiB
Rust
50 lines
1.0 KiB
Rust
use super::item_category::{BattleItemCategory, ItemCategory};
|
|
use std::collections::HashSet;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Item {
|
|
name: String,
|
|
category: ItemCategory,
|
|
battle_category: BattleItemCategory,
|
|
price: i32,
|
|
flags: HashSet<String>,
|
|
}
|
|
|
|
impl Item {
|
|
pub fn new(
|
|
name: &str,
|
|
category: ItemCategory,
|
|
battle_category: BattleItemCategory,
|
|
price: i32,
|
|
flags: HashSet<String>,
|
|
) -> Item {
|
|
Item {
|
|
name: name.to_string(),
|
|
category,
|
|
battle_category,
|
|
price,
|
|
flags,
|
|
}
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
&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<String> {
|
|
&self.flags
|
|
}
|
|
|
|
pub fn has_flag(&self, key: &str) -> bool {
|
|
self.flags.contains(key)
|
|
}
|
|
}
|