2019-12-09 23:11:27 -08:00
|
|
|
use libpso::item;
|
2020-01-18 23:36:28 -08:00
|
|
|
use libpso::character::character;
|
2019-12-09 23:11:27 -08:00
|
|
|
|
|
|
|
|
2020-01-18 23:36:28 -08:00
|
|
|
#[derive(PartialEq, Copy, Clone, Debug, Hash, Eq)]
|
|
|
|
pub struct ItemEntityId(pub u32);
|
|
|
|
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
|
|
|
pub struct ItemId(u32);
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2019-12-09 23:11:27 -08:00
|
|
|
pub enum ItemLocation {
|
|
|
|
Inventory {
|
|
|
|
character_id: u32,
|
|
|
|
index: usize,
|
|
|
|
},
|
|
|
|
Bank {
|
|
|
|
character_id: u32,
|
2020-01-18 23:36:28 -08:00
|
|
|
slot: usize,
|
2019-12-09 23:11:27 -08:00
|
|
|
},
|
|
|
|
Floor {
|
|
|
|
// floor: eventually
|
|
|
|
// x y z: ?????
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-18 23:36:28 -08:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Weapon {
|
|
|
|
pub equipped: bool,
|
|
|
|
pub weapon: item::weapon::Weapon,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Armor {
|
|
|
|
pub equipped: bool,
|
|
|
|
pub armor: item::armor::Armor,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Shield {
|
|
|
|
pub equipped: bool,
|
|
|
|
pub shield: item::shield::Shield,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Tool {
|
|
|
|
pub tool: item::tool::ToolType,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Tool {
|
|
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
|
let mut result = [0; 16];
|
|
|
|
result[0..3].copy_from_slice(&self.tool.value());
|
|
|
|
result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub enum ItemDetail {
|
|
|
|
Weapon(Weapon),
|
|
|
|
Armor(Armor),
|
|
|
|
Shield(Shield),
|
|
|
|
Tool(Tool),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ItemDetail {
|
|
|
|
pub fn is_stackable(&self) -> bool {
|
|
|
|
match self {
|
|
|
|
ItemDetail::Tool(tool) => true,
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
|
match self {
|
|
|
|
ItemDetail::Weapon(weapon) => weapon.weapon.as_bytes(),
|
|
|
|
ItemDetail::Armor(armor) => armor.armor.as_bytes(),
|
|
|
|
ItemDetail::Shield(shield) => shield.shield.as_bytes(),
|
|
|
|
ItemDetail::Tool(tool) => tool.as_bytes(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2019-12-09 23:11:27 -08:00
|
|
|
pub struct Item {
|
2020-01-18 23:36:28 -08:00
|
|
|
pub id: ItemEntityId,
|
2019-12-09 23:11:27 -08:00
|
|
|
pub location: ItemLocation,
|
2020-01-18 23:36:28 -08:00
|
|
|
pub item: ItemDetail,
|
2019-12-09 23:11:27 -08:00
|
|
|
}
|