|
|
@ -1,14 +1,11 @@ |
|
|
|
use crate::ship::items::ClientItemId;
|
|
|
|
use std::collections::{HashMap, BTreeMap, BinaryHeap};
|
|
|
|
use std::cmp::{Ordering, PartialOrd, PartialEq};
|
|
|
|
use std::collections::{HashMap, BTreeMap};
|
|
|
|
use thiserror::Error;
|
|
|
|
use futures::future::join_all;
|
|
|
|
use libpso::character::character;//::InventoryItem;
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
|
|
|
use crate::entity::item::{ItemEntityId, ItemEntity, ItemDetail, ItemLocation, BankName};
|
|
|
|
use crate::entity::item::{ItemDetail, ItemLocation, BankName};
|
|
|
|
use crate::entity::item::{Meseta, NewItemEntity};
|
|
|
|
use crate::entity::item::tool::{Tool, ToolType};
|
|
|
|
use crate::entity::item::tool::Tool;
|
|
|
|
use crate::ship::map::MapArea;
|
|
|
|
use crate::ship::ship::ItemDropLocation;
|
|
|
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
|
|
@ -117,7 +114,7 @@ impl ItemManager { |
|
|
|
})
|
|
|
|
.into_iter()
|
|
|
|
.map(|(bank_name, bank_items)| {
|
|
|
|
let mut stacked_bank_items = bank_items.into_iter()
|
|
|
|
let stacked_bank_items = bank_items.into_iter()
|
|
|
|
.fold(Vec::new(), |mut acc, (id, bank_item)| {
|
|
|
|
if bank_item.is_stackable() {
|
|
|
|
let existing_item = acc.iter_mut()
|
|
|
@ -163,7 +160,7 @@ impl ItemManager { |
|
|
|
self.character_inventory.insert(character.id, inventory);
|
|
|
|
self.character_bank.insert(character.id, bank_items);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn add_character_to_room(&mut self, room_id: RoomId, character: &CharacterEntity, area_client: AreaClient) {
|
|
|
|
let base_inventory_id = ((area_client.local_client.id() as u32) << 21) | 0x10000;
|
|
|
|
let inventory = self.character_inventory.get_mut(&character.id).unwrap();
|
|
|
@ -216,7 +213,7 @@ impl ItemManager { |
|
|
|
let local_floor = self.character_floor.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
let room = self.character_room.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
let shared_floor = self.room_floor.get(room).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
|
|
|
|
|
|
|
|
local_floor.get_item_by_id(item_id)
|
|
|
|
.or_else(|| {
|
|
|
|
shared_floor.get_item_by_id(item_id)
|
|
|
@ -302,7 +299,7 @@ impl ItemManager { |
|
|
|
floor_item.remove_from_floor();
|
|
|
|
Ok(trigger_create_item)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn enemy_drop_item_on_local_floor<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, character: &CharacterEntity, item_drop: ItemDrop) -> Result<&FloorItem, ItemManagerError> {
|
|
|
|
let room_id = self.character_room.get(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
|
|
|
|
|
|
@ -382,7 +379,7 @@ impl ItemManager { |
|
|
|
})
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
self.character_floor.entry(character.id).or_insert(RoomFloorItems::new()).add_item(floor_item);
|
|
|
|
// TODO: make these real errors
|
|
|
|
self.character_floor.get(&character.id).ok_or(ItemManagerError::Idunnoman)?.get_item_by_id(item_id).ok_or(ItemManagerError::Idunnoman)
|
|
|
@ -513,20 +510,20 @@ impl ItemManager { |
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn player_deposits_item<EG: EntityGateway>(&mut self,
|
|
|
|
entity_gateway: &mut EG,
|
|
|
|
character: &CharacterEntity,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
amount: usize)
|
|
|
|
_entity_gateway: &mut EG,
|
|
|
|
_character: &CharacterEntity,
|
|
|
|
_item_id: ClientItemId,
|
|
|
|
_amount: usize)
|
|
|
|
-> Result<(), ItemManagerError> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn player_withdraws_item<EG: EntityGateway>(&mut self,
|
|
|
|
entity_gateway: &mut EG,
|
|
|
|
character: &CharacterEntity,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
amount: usize)
|
|
|
|
-> Result<(), ItemManagerError> {
|
|
|
|
_entity_gateway: &mut EG,
|
|
|
|
_character: &CharacterEntity,
|
|
|
|
_item_id: ClientItemId,
|
|
|
|
_amount: usize)
|
|
|
|
-> Result<(), ItemManagerError> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|