Browse Source

make these a bit more public for tests

pull/80/head
jake 3 years ago
parent
commit
70a6764360
  1. 6
      src/ship/items/floor.rs
  2. 14
      src/ship/items/manager.rs

6
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<FloorItemHandle> {
let index = self.0.iter().position(|item| item.item_id() == item_id)?;
Some(FloorItemHandle {

14
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<CharacterEntityId, CharacterInventory>,
pub(self) character_inventory: HashMap<CharacterEntityId, CharacterInventory>,
//character_bank: HashMap<CharacterEntityId, BTreeMap<BankName, CharacterBank>>,
character_bank: HashMap<CharacterEntityId, CharacterBank>,
character_floor: HashMap<CharacterEntityId, RoomFloorItems>,
pub(self) character_bank: HashMap<CharacterEntityId, CharacterBank>,
pub(self) character_floor: HashMap<CharacterEntityId, RoomFloorItems>,
character_room: HashMap<CharacterEntityId, RoomId>,
room_floor: HashMap<RoomId, RoomFloorItems>,
room_item_id_counter: HashMap<RoomId, Box<dyn FnMut() -> ClientItemId + Send>>,
pub(self) character_room: HashMap<CharacterEntityId, RoomId>,
pub(self) room_floor: HashMap<RoomId, RoomFloorItems>,
pub(self) room_item_id_counter: HashMap<RoomId, Box<dyn FnMut() -> ClientItemId + Send>>,
}
impl Default for ItemManager {

Loading…
Cancel
Save