100 lines
2.3 KiB
Rust
Raw Normal View History

pub mod weapon;
pub mod armor;
pub mod shield;
pub mod tool;
2020-03-18 18:21:34 -07:00
pub mod tech;
2020-02-29 14:50:17 -08:00
pub mod unit;
2020-03-14 20:26:12 -07:00
pub mod mag;
2020-03-29 14:40:24 -07:00
use crate::entity::character::CharacterEntityId;
#[derive(PartialEq, Copy, Clone, Debug, Hash, Eq)]
pub struct ItemEntityId(pub u32);
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
pub struct ItemId(u32);
2020-03-29 14:40:24 -07:00
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BankName(String);
#[derive(Clone, Debug, PartialEq)]
2019-12-09 23:11:27 -08:00
pub enum ItemLocation {
Inventory {
2020-03-29 14:40:24 -07:00
character_id: CharacterEntityId,
2019-12-09 23:11:27 -08:00
index: usize,
equipped: bool,
2019-12-09 23:11:27 -08:00
},
Bank {
2020-03-29 14:40:24 -07:00
character_id: CharacterEntityId,
slot: BankName,
2019-12-09 23:11:27 -08:00
},
Floor {
// floor: eventually
// x y z: ?????
},
/*Destroyed {
// marks an item that has been consumed in some way
},
Transformed {
item_id,
change_event
}
*/
2019-12-09 23:11:27 -08:00
}
2020-03-21 17:47:28 -07:00
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum ItemType {
Weapon(weapon::WeaponType),
Armor(armor::ArmorType),
Shield(shield::ShieldType),
Unit(unit::UnitType),
Tool(tool::ToolType),
2020-03-21 21:46:52 -07:00
TechniqueDisk(tech::Technique),
Mag(mag::MagType),
}
2020-03-21 17:47:28 -07:00
#[derive(Clone, Debug, PartialEq)]
pub enum ItemDetail {
Weapon(weapon::Weapon),
2020-03-16 20:57:19 -07:00
Armor(armor::Armor),
2020-03-16 21:48:26 -07:00
Shield(shield::Shield),
Unit(unit::Unit),
2020-03-21 17:47:28 -07:00
Tool(tool::Tool),
2020-03-21 21:46:52 -07:00
TechniqueDisk(tech::TechniqueDisk),
Mag(mag::Mag),
}
impl ItemDetail {
pub fn is_stackable(&self) -> bool {
match self {
ItemDetail::Tool(tool) => tool.tool.is_stackable(),
_ => false,
}
}
2020-03-21 17:47:28 -07:00
pub fn item_type(&self) -> ItemType {
match self {
2020-03-21 17:47:28 -07:00
ItemDetail::Weapon(w) => ItemType::Weapon(w.weapon),
ItemDetail::Armor(a) => ItemType::Armor(a.armor),
ItemDetail::Shield(s) => ItemType::Shield(s.shield),
ItemDetail::Unit(u) => ItemType::Unit(u.unit),
ItemDetail::Tool(t) => ItemType::Tool(t.tool),
ItemDetail::TechniqueDisk(d) => ItemType::TechniqueDisk(d.tech),
2020-03-21 21:46:52 -07:00
ItemDetail::Mag(m) => ItemType::Mag(m.mag),
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct NewItemEntity {
pub location: ItemLocation,
pub item: ItemDetail,
}
#[derive(Clone, Debug, PartialEq)]
2020-03-29 14:53:51 -07:00
pub struct ItemEntity {
pub id: ItemEntityId,
2019-12-09 23:11:27 -08:00
pub location: ItemLocation,
pub item: ItemDetail,
2019-12-09 23:11:27 -08:00
}