From 70a6764360f779deec0fd2c26b00fbff894bd5ff Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 27 Sep 2021 23:46:03 -0600 Subject: [PATCH] make these a bit more public for tests --- src/ship/items/floor.rs | 6 ++++++ src/ship/items/manager.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ship/items/floor.rs b/src/ship/items/floor.rs index c976048..271880c 100644 --- a/src/ship/items/floor.rs +++ b/src/ship/items/floor.rs @@ -173,10 +173,16 @@ impl RoomFloorItems { self.0.push(item); } + pub fn remove_item(&mut self, item_id: &ClientItemId) { + self.0.retain(|item| item.item_id() != *item_id); + } + + // TODO: &ClientItemId pub fn get_item_by_id(&self, item_id: ClientItemId) -> Option<&FloorItem> { self.0.iter().find(|item| item.item_id() == item_id) } + // TODO: &ClientItemId pub fn get_item_handle_by_id(&mut self, item_id: ClientItemId) -> Option { let index = self.0.iter().position(|item| item.item_id() == item_id)?; Some(FloorItemHandle { diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index d3fdf0e..e51b412 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -58,16 +58,16 @@ pub enum ItemManagerError { } pub struct ItemManager { - id_counter: u32, + pub(super) id_counter: u32, - character_inventory: HashMap, + pub(self) character_inventory: HashMap, //character_bank: HashMap>, - character_bank: HashMap, - character_floor: HashMap, + pub(self) character_bank: HashMap, + pub(self) character_floor: HashMap, - character_room: HashMap, - room_floor: HashMap, - room_item_id_counter: HashMap ClientItemId + Send>>, + pub(self) character_room: HashMap, + pub(self) room_floor: HashMap, + pub(self) room_item_id_counter: HashMap ClientItemId + Send>>, } impl Default for ItemManager {