51 lines
1.1 KiB
Rust
51 lines
1.1 KiB
Rust
use super::item_category::{BattleItemCategory, ItemCategory};
|
|
use crate::StringKey;
|
|
use std::collections::HashSet;
|
|
|
|
#[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)
|
|
}
|
|
}
|