From 4b78a110f0d4f3181860e5bdf98602c3a351a84d Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 16 Nov 2020 21:55:24 -0700 Subject: [PATCH] anyhow the rest of the itemmanager --- src/ship/items/manager.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index d102a4b..f3986f7 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -223,7 +223,7 @@ impl ItemManager { } pub async fn character_picks_up_item(&mut self, entity_gateway: &mut EG, character: &mut CharacterEntity, item_id: ClientItemId) - -> Result { + -> Result { let local_floor = self.character_floor.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; let room_id = self.character_room.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; @@ -251,7 +251,7 @@ impl ItemManager { } }, None => { - return Err(ItemManagerError::CouldNotAddToInventory(item_id)); + return Err(ItemManagerError::CouldNotAddToInventory(item_id).into()); }, } TriggerCreateItem::Yes @@ -278,20 +278,20 @@ impl ItemManager { } }, None => { - return Err(ItemManagerError::CouldNotAddToInventory(item_id)); + return Err(ItemManagerError::CouldNotAddToInventory(item_id).into()); } } }, Some(FloorItem::Meseta(meseta_floor_item)) => { if character.meseta >= 999999 { - return Err(ItemManagerError::CouldNotAddToInventory(item_id)); + return Err(ItemManagerError::CouldNotAddToInventory(item_id).into()); } character.meseta = std::cmp::min(character.meseta + meseta_floor_item.meseta.0, 999999); entity_gateway.save_character(&character).await?; TriggerCreateItem::No }, None => { - return Err(ItemManagerError::CouldNotAddToInventory(item_id)); + return Err(ItemManagerError::CouldNotAddToInventory(item_id).into()); } }; @@ -391,7 +391,7 @@ impl ItemManager { //inventory_item: InventoryItem, item_id: ClientItemId, item_drop_location: (MapArea, f32, f32, f32)) - -> Result<(), ItemManagerError> { + -> Result<(), anyhow::Error> { let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; let room_id = self.character_room.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; let shared_floor = self.room_floor.get_mut(&room_id).ok_or(ItemManagerError::NoCharacter(character.id))?; @@ -436,11 +436,11 @@ impl ItemManager { character: &mut CharacterEntity, drop_location: ItemDropLocation, amount: u32) - -> Result { + -> Result { let room_id = self.character_room.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?; let shared_floor = self.room_floor.get_mut(&room_id).ok_or(ItemManagerError::NoCharacter(character.id))?; if character.meseta < amount { - return Err(ItemManagerError::CouldNotDropMeseta) + return Err(ItemManagerError::CouldNotDropMeseta.into()) } character.meseta -= amount; entity_gateway.save_character(&character).await?;