35 lines
740 B
Rust
35 lines
740 B
Rust
|
use super::item_category::{BattleItemCategory, ItemCategory};
|
||
|
use derive_getters::Getters;
|
||
|
use std::collections::HashSet;
|
||
|
|
||
|
#[derive(Getters, 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 has_flag(&self, key: &str) -> bool {
|
||
|
self.flags.contains(key)
|
||
|
}
|
||
|
}
|