diff --git a/src/entity/gateway/entitygateway.rs b/src/entity/gateway/entitygateway.rs index c478dcb..ebbe509 100644 --- a/src/entity/gateway/entitygateway.rs +++ b/src/entity/gateway/entitygateway.rs @@ -41,15 +41,15 @@ pub trait EntityGateway { unimplemented!(); } - fn new_item(&mut self, _item: ItemDetail, _location: ItemLocation) -> Item { + fn new_item(&mut self, _item: ItemDetail, _location: ItemLocation) -> ItemEntity { unimplemented!(); } - fn set_item(&self, _item: &Item) { + fn set_item(&self, _item: &ItemEntity) { unimplemented!(); } - fn get_items_by_character(&self, _char: &CharacterEntity) -> Vec { + fn get_items_by_character(&self, _char: &CharacterEntity) -> Vec { unimplemented!(); } } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 292024a..1c93af8 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -16,7 +16,7 @@ pub struct InMemoryGateway { users: Arc>>, user_settings: Arc>>, characters: Arc>>, - items: Arc>>, + items: Arc>>, } impl InMemoryGateway { @@ -105,13 +105,13 @@ impl EntityGateway for InMemoryGateway { GuildCardData::default() } - fn new_item(&mut self, item: ItemDetail, location: ItemLocation) -> Item { + fn new_item(&mut self, item: ItemDetail, location: ItemLocation) -> ItemEntity { let mut items = self.items.lock().unwrap(); let id = items .iter() .fold(0, |sum, (i, _)| std::cmp::max(sum, i.0)) + 1; - let new_item = Item { + let new_item = ItemEntity { id: ItemEntityId(id), location: location, item: item, @@ -120,12 +120,12 @@ impl EntityGateway for InMemoryGateway { new_item } - fn set_item(&self, item: &Item) { + fn set_item(&self, item: &ItemEntity) { let mut items = self.items.lock().unwrap(); items.insert(item.id, item.clone()); } - fn get_items_by_character(&self, character: &CharacterEntity) -> Vec { + fn get_items_by_character(&self, character: &CharacterEntity) -> Vec { let items = self.items.lock().unwrap(); items .iter() diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index 9895bfb..1cdb96b 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -87,7 +87,7 @@ impl ItemDetail { #[derive(Clone, Debug, PartialEq)] -pub struct Item { +pub struct ItemEntity { pub id: ItemEntityId, pub location: ItemLocation, pub item: ItemDetail, diff --git a/src/ship/items.rs b/src/ship/items.rs index 7a11221..77fd88f 100644 --- a/src/ship/items.rs +++ b/src/ship/items.rs @@ -4,7 +4,7 @@ use libpso::character::character::InventoryItem; use crate::entity::gateway::EntityGateway; use crate::entity::character::CharacterEntity; -use crate::entity::item::{Item, ItemId, ItemDetail, ItemLocation}; +use crate::entity::item::{ItemEntity, ItemId, ItemDetail, ItemLocation}; use crate::entity::item::weapon::Weapon; use crate::entity::item::armor::Armor; use crate::entity::item::shield::Shield; @@ -15,8 +15,8 @@ use crate::entity::item::mag::Mag; #[derive(Debug, PartialEq)] pub enum StackedItem { - Individual(Item), - Stacked(Vec), + Individual(ItemEntity), + Stacked(Vec), } #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -68,12 +68,12 @@ impl ActiveInventory { // does this do anything? inventory[index].equipped = match item.item { - StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 1, + StackedItem::Individual(ItemEntity {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 1, _ => 0, }; // because this actually equips the item inventory[index].flags |= match item.item { - StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 8, + StackedItem::Individual(ItemEntity {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 8, _ => 0, }; inventory @@ -102,7 +102,7 @@ fn inventory_item_index(item: &StackedItem) -> usize { } } -fn stack_items(items: Vec) -> Vec { +fn stack_items(items: Vec) -> Vec { let mut stacks = HashMap::new(); for item in items { @@ -174,10 +174,10 @@ mod test { use super::*; use crate::entity::character::CharacterEntityId; use crate::entity::item; - use crate::entity::item::{Item, ItemDetail, ItemEntityId, ItemLocation}; + use crate::entity::item::{ItemEntity, ItemDetail, ItemEntityId, ItemLocation}; #[test] fn test_stack_items() { - let item1 = Item { + let item1 = ItemEntity { id: ItemEntityId(1), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -192,7 +192,7 @@ mod test { tekked: true, }) }; - let item2 = Item { + let item2 = ItemEntity { id: ItemEntityId(2), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -203,7 +203,7 @@ mod test { tool: item::tool::ToolType::Monofluid, }) }; - let item3 = Item { + let item3 = ItemEntity { id: ItemEntityId(3), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -218,7 +218,7 @@ mod test { tekked: true, }) }; - let item4 = Item { + let item4 = ItemEntity { id: ItemEntityId(4), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -229,7 +229,7 @@ mod test { tool: item::tool::ToolType::Monofluid, }) }; - let item5 = Item { + let item5 = ItemEntity { id: ItemEntityId(5), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -240,7 +240,7 @@ mod test { tool: item::tool::ToolType::Monofluid, }) }; - let item6 = Item { + let item6 = ItemEntity { id: ItemEntityId(6), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -255,7 +255,7 @@ mod test { tekked: true, }) }; - let item7 = Item { + let item7 = ItemEntity { id: ItemEntityId(7), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -266,7 +266,7 @@ mod test { tool: item::tool::ToolType::Monomate, }) }; - let item8 = Item { + let item8 = ItemEntity { id: ItemEntityId(8), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), @@ -277,7 +277,7 @@ mod test { tool: item::tool::ToolType::Monomate, }) }; - let item9 = Item { + let item9 = ItemEntity { id: ItemEntityId(9), location: ItemLocation::Inventory { character_id: CharacterEntityId(0), diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 518d874..5dbb472 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -19,7 +19,7 @@ use crate::common::leveltable::CharacterLevelTable; use crate::entity::gateway::EntityGateway; use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; use crate::entity::character::CharacterEntity; -use crate::entity::item::{ItemLocation, Item}; +use crate::entity::item::{ItemLocation, ItemEntity}; use crate::login::login::get_login_status; use crate::ship::location::{ClientLocation, LobbyId, RoomId, AreaType, MAX_ROOMS}; use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder};