|
|
@ -6,12 +6,12 @@ use std::pin::Pin; |
|
|
|
|
|
|
|
use crate::ship::map::MapArea;
|
|
|
|
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
|
|
|
use crate::entity::gateway::EntityGatewayTransaction;
|
|
|
|
use crate::entity::gateway::{EntityGateway, EntityGatewayTransaction};
|
|
|
|
use crate::ship::items::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail};
|
|
|
|
use crate::ship::items::bank::{BankItem, BankItemDetail};
|
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
|
use crate::ship::items::floor::{FloorItem, FloorItemDetail};
|
|
|
|
use crate::ship::items::apply_item::apply_item;
|
|
|
|
use crate::ship::items::apply_item::{apply_item, ApplyItemAction};
|
|
|
|
use crate::entity::item::{ItemDetail, NewItemEntity, TradeId};
|
|
|
|
use crate::entity::item::tool::Tool;
|
|
|
|
use crate::entity::item::ItemModifier;
|
|
|
@ -23,11 +23,16 @@ pub enum TriggerCreateItem { |
|
|
|
No
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn take_item_from_floor(character_id: CharacterEntityId, item_id: ClientItemId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn take_item_from_floor<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_id: ClientItemId
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), FloorItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway + Send,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction): (ItemStateProxy<'_>, Box<dyn EntityGatewayTransaction + '_>) , _| {
|
|
|
|
move |(mut item_state, transaction): (ItemStateProxy, TR) , _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut floor = item_state.floor(&character_id).await?;
|
|
|
|
let item = floor.take_item(&item_id).ok_or_else(|| ItemStateError::NoFloorItem(item_id))?;
|
|
|
@ -38,13 +43,18 @@ pub(super) fn take_item_from_floor(character_id: CharacterEntityId, item_id: Cli |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_floor_item_to_inventory(character: &CharacterEntity)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), TriggerCreateItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_floor_item_to_inventory<EG, TR>(
|
|
|
|
character: &CharacterEntity
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), TriggerCreateItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + Clone + 'static,
|
|
|
|
{
|
|
|
|
let character = character.clone();
|
|
|
|
move |(mut item_state, transaction), floor_item| {
|
|
|
|
let character = character.clone();
|
|
|
|
let transaction = transaction.clone();
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut inventory = item_state.inventory(&character.id).await?;
|
|
|
|
|
|
|
@ -67,7 +77,7 @@ pub(super) fn add_floor_item_to_inventory(character: &CharacterEntity) |
|
|
|
let add_result = inventory.add_floor_item(floor_item)?;
|
|
|
|
transaction.gateway().set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction),
|
|
|
|
match add_result {
|
|
|
@ -81,9 +91,15 @@ pub(super) fn add_floor_item_to_inventory(character: &CharacterEntity) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn take_item_from_inventory(character_id: CharacterEntityId, item_id: ClientItemId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn take_item_from_inventory<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -91,7 +107,7 @@ pub(super) fn take_item_from_inventory(character_id: CharacterEntityId, item_id: |
|
|
|
let item = inventory.take_item(&item_id, amount).ok_or_else(|| ItemStateError::NoFloorItem(item_id))?;
|
|
|
|
|
|
|
|
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), item))
|
|
|
|
})
|
|
|
@ -99,9 +115,15 @@ pub(super) fn take_item_from_inventory(character_id: CharacterEntityId, item_id: |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn add_inventory_item_to_shared_floor(character_id: CharacterEntityId, map_area: MapArea, drop_position: (f32, f32, f32))
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_inventory_item_to_shared_floor<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
map_area: MapArea,
|
|
|
|
drop_position: (f32, f32, f32),
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), FloorItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -127,43 +149,59 @@ pub(super) fn add_inventory_item_to_shared_floor(character_id: CharacterEntityId |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn take_meseta_from_inventory(character_id: CharacterEntityId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn take_meseta_from_inventory<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut inventory = item_state.inventory(&character_id).await?;
|
|
|
|
inventory.remove_meseta(amount)?;
|
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_meseta_to_inventory(character_id: CharacterEntityId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_meseta_to_inventory<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32 |
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut inventory = item_state.inventory(&character_id).await?;
|
|
|
|
inventory.add_meseta(amount)?;
|
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_meseta_to_shared_floor(character_id: CharacterEntityId, amount: u32, map_area: MapArea, drop_position: (f32, f32))
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_meseta_to_shared_floor<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32,
|
|
|
|
map_area: MapArea,
|
|
|
|
drop_position: (f32, f32)
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), FloorItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
|
|
|
|
move |(mut item_state, transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let floor_item = FloorItem {
|
|
|
@ -184,9 +222,14 @@ pub(super) fn add_meseta_to_shared_floor(character_id: CharacterEntityId, amount |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn take_meseta_from_bank(character_id: CharacterEntityId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn take_meseta_from_bank<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -199,9 +242,14 @@ pub(super) fn take_meseta_from_bank(character_id: CharacterEntityId, amount: u32 |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_meseta_from_bank_to_inventory(character_id: CharacterEntityId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_meseta_from_bank_to_inventory<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -215,9 +263,14 @@ pub(super) fn add_meseta_from_bank_to_inventory(character_id: CharacterEntityId, |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn add_meseta_to_bank(character_id: CharacterEntityId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_meseta_to_bank<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -231,25 +284,35 @@ pub(super) fn add_meseta_to_bank(character_id: CharacterEntityId, amount: u32) |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn take_item_from_bank(character_id: CharacterEntityId, item_id: ClientItemId, amount: u32)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), BankItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn take_item_from_bank<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), BankItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut bank = item_state.bank(&character_id).await?;
|
|
|
|
let item = bank.take_item(&item_id, amount).ok_or_else(|| ItemStateError::NoBankItem(item_id))?;
|
|
|
|
transaction.gateway().set_character_bank(&character_id, &bank.as_bank_entity(), &bank.name).await?;
|
|
|
|
item_state.set_bank(bank);
|
|
|
|
item_state.set_bank(bank).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), item))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_bank_item_to_inventory(character: &CharacterEntity)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), BankItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_bank_item_to_inventory<EG, TR>(
|
|
|
|
character: &CharacterEntity,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), BankItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
let character = character.clone();
|
|
|
|
move |(mut item_state, transaction), bank_item| {
|
|
|
@ -286,7 +349,7 @@ pub(super) fn add_bank_item_to_inventory(character: &CharacterEntity) |
|
|
|
|
|
|
|
inventory.add_item(inventory_item.clone())?;
|
|
|
|
transaction.gateway().set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), inventory_item))
|
|
|
|
})
|
|
|
@ -294,9 +357,13 @@ pub(super) fn add_bank_item_to_inventory(character: &CharacterEntity) |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn add_inventory_item_to_bank(character_id: CharacterEntityId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_inventory_item_to_bank<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -315,7 +382,7 @@ pub(super) fn add_inventory_item_to_bank(character_id: CharacterEntityId) |
|
|
|
bank.add_inventory_item(inventory_item)?;
|
|
|
|
|
|
|
|
transaction.gateway().set_character_bank(&character_id, &bank.as_bank_entity(), &bank.name).await?;
|
|
|
|
item_state.set_bank(bank);
|
|
|
|
item_state.set_bank(bank).await;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
@ -324,16 +391,22 @@ pub(super) fn add_inventory_item_to_bank(character_id: CharacterEntityId) |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn equip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId, equip_slot: u8)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn equip_inventory_item<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
equip_slot: u8,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut inventory = item_state.inventory(&character_id).await?;
|
|
|
|
inventory.equip(&item_id, equip_slot);
|
|
|
|
transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
|
})
|
|
|
@ -341,16 +414,21 @@ pub(super) fn equip_inventory_item(character_id: CharacterEntityId, item_id: Cli |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn unequip_inventory_item(character_id: CharacterEntityId, item_id: ClientItemId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn unequip_inventory_item<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_id: ClientItemId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut inventory = item_state.inventory(&character_id).await?;
|
|
|
|
inventory.unequip(&item_id);
|
|
|
|
transaction.gateway().set_character_equips(&character_id, &inventory.as_equipped_entity()).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
|
})
|
|
|
@ -359,9 +437,14 @@ pub(super) fn unequip_inventory_item(character_id: CharacterEntityId, item_id: C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn sort_inventory_items(character_id: CharacterEntityId, item_ids: Vec<ClientItemId>)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn sort_inventory_items<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_ids: Vec<ClientItemId>,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), ()), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
let item_ids = item_ids.clone();
|
|
|
@ -369,7 +452,7 @@ pub(super) fn sort_inventory_items(character_id: CharacterEntityId, item_ids: Ve |
|
|
|
let mut inventory = item_state.inventory(&character_id).await?;
|
|
|
|
inventory.sort(&item_ids);
|
|
|
|
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), ()))
|
|
|
|
})
|
|
|
@ -377,9 +460,13 @@ pub(super) fn sort_inventory_items(character_id: CharacterEntityId, item_ids: Ve |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn use_consumed_item(character: CharacterEntity)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), CharacterEntity), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn use_consumed_item<EG, TR>(
|
|
|
|
character: CharacterEntity,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), Vec<ApplyItemAction>), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway + Clone + 'static,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
let mut character = character.clone();
|
|
|
@ -390,17 +477,22 @@ pub(super) fn use_consumed_item(character: CharacterEntity) |
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
apply_item(&mut item_state, transaction.gateway(), &mut character, inventory_item).await?;
|
|
|
|
let apply_item_actions = apply_item(&mut item_state, transaction.gateway(), &mut character, inventory_item).await?;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), character))
|
|
|
|
Ok(((item_state, transaction), apply_item_actions))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn feed_mag_item(character: CharacterEntity, mag_item_id: ClientItemId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), CharacterEntity), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn feed_mag_item<EG, TR>(
|
|
|
|
character: CharacterEntity,
|
|
|
|
mag_item_id: ClientItemId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), CharacterEntity), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), tool| {
|
|
|
|
let character = character.clone();
|
|
|
@ -437,7 +529,7 @@ pub(super) fn feed_mag_item(character: CharacterEntity, mag_item_id: ClientItemI |
|
|
|
mag_entity.feed(food_tool);
|
|
|
|
|
|
|
|
transaction.gateway().set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), character))
|
|
|
|
})
|
|
|
@ -445,12 +537,16 @@ pub(super) fn feed_mag_item(character: CharacterEntity, mag_item_id: ClientItemI |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn add_bought_item_to_inventory<'a>(character_id: CharacterEntityId,
|
|
|
|
pub(super) fn add_bought_item_to_inventory<'a, EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
shop_item: &'a (dyn ShopItem + Send + Sync),
|
|
|
|
item_id: ClientItemId,
|
|
|
|
amount: u32)
|
|
|
|
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
amount: u32,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -499,16 +595,20 @@ pub(super) fn add_bought_item_to_inventory<'a>(character_id: CharacterEntityId, |
|
|
|
};
|
|
|
|
|
|
|
|
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
Ok(((item_state, transaction), inventory_item))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn sell_inventory_item<'a>(character_id: CharacterEntityId)
|
|
|
|
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn sell_inventory_item<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -522,7 +622,7 @@ pub(super) fn sell_inventory_item<'a>(character_id: CharacterEntityId) |
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
Ok(((item_state, transaction), inventory_item))
|
|
|
|
})
|
|
|
|
}
|
|
|
@ -530,19 +630,22 @@ pub(super) fn sell_inventory_item<'a>(character_id: CharacterEntityId) |
|
|
|
|
|
|
|
|
|
|
|
#[async_recursion::async_recursion]
|
|
|
|
async fn iterate_inner<'a, I, O, T, F, FR>(state: (ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>),
|
|
|
|
async fn iterate_inner<'a, EG, TR, I, O, T, F, FR>(
|
|
|
|
state: (ItemStateProxy, TR),
|
|
|
|
mut input: Vec<I>,
|
|
|
|
func: F,
|
|
|
|
arg: T)
|
|
|
|
-> Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<O>), ItemStateError>
|
|
|
|
arg: T,
|
|
|
|
) -> Result<((ItemStateProxy, TR), Vec<O>), ItemStateError>
|
|
|
|
where
|
|
|
|
'a: 'async_recursion,
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG>,
|
|
|
|
I: Send,
|
|
|
|
O: Send,
|
|
|
|
T: Clone + Send + Sync,
|
|
|
|
F: Fn(I) -> FR + Send + Sync + Clone + 'static,
|
|
|
|
FR: Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync,
|
|
|
|
FR: Fn((ItemStateProxy, TR), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), O), ItemStateError>> + Send>> + Send + Sync,
|
|
|
|
{
|
|
|
|
let item = match input.pop() {
|
|
|
|
Some(item) => item,
|
|
|
@ -558,18 +661,20 @@ where |
|
|
|
Ok((state, output))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn iterate<'k, I, O, T, F, FR>(
|
|
|
|
pub(super) fn iterate<'k, EG, TR, I, O, T, F, FR>(
|
|
|
|
input: Vec<I>,
|
|
|
|
func: F)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<O>), ItemStateError>> + Send + 'a>>
|
|
|
|
func: F,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), Vec<O>), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
O: Send,
|
|
|
|
I: Send + Clone + 'static + std::fmt::Debug,
|
|
|
|
T: Send + Clone + 'static + std::fmt::Debug,
|
|
|
|
F: Fn(I) -> FR + Send + Sync + Clone + 'static,
|
|
|
|
FR: for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync,
|
|
|
|
FR: Fn((ItemStateProxy, TR), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), O), ItemStateError>> + Send>> + Send + Sync,
|
|
|
|
T: Clone + Send + Sync,
|
|
|
|
{
|
|
|
|
move |(item_state, transaction), arg| {
|
|
|
@ -584,16 +689,19 @@ where |
|
|
|
|
|
|
|
|
|
|
|
#[async_recursion::async_recursion]
|
|
|
|
async fn foreach_inner<'a, O, T, F>(state: (ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>),
|
|
|
|
async fn foreach_inner<'a, EG, TR, O, T, F>(
|
|
|
|
state: (ItemStateProxy, TR),
|
|
|
|
mut input: Vec<T>,
|
|
|
|
func: F)
|
|
|
|
-> Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<O>), ItemStateError>
|
|
|
|
func: F,
|
|
|
|
) -> Result<((ItemStateProxy, TR), Vec<O>), ItemStateError>
|
|
|
|
where
|
|
|
|
'a: 'async_recursion,
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
O: Send,
|
|
|
|
T: Clone + Send,
|
|
|
|
F: Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync,
|
|
|
|
F: Fn((ItemStateProxy, TR), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), O), ItemStateError>> + Send>> + Send + Sync,
|
|
|
|
F: Clone,
|
|
|
|
{
|
|
|
|
let item = match input.pop() {
|
|
|
@ -609,14 +717,17 @@ where |
|
|
|
Ok((state, output))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn foreach<'k, O, T, F>(func: F)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<T>)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<O>), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn foreach<'k, EG, TR, O, T, F>(
|
|
|
|
func: F
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), Vec<T>)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), Vec<O>), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
O: Send,
|
|
|
|
T: Send + Clone + 'static + std::fmt::Debug,
|
|
|
|
F: for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync + 'static,
|
|
|
|
F: Fn((ItemStateProxy, TR), T)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), O), ItemStateError>> + Send>> + Send + Sync + 'static,
|
|
|
|
F: Clone,
|
|
|
|
T: Clone + Send + Sync,
|
|
|
|
{
|
|
|
@ -629,9 +740,14 @@ where |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn insert<'a, T: Send + Clone + 'a>(element: T)
|
|
|
|
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn insert<'a, EG, TR, T>(
|
|
|
|
element: T
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), T), ItemStateError>> + Send + 'a>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
T: Send + Clone + 'a,
|
|
|
|
{
|
|
|
|
move |state, _| {
|
|
|
|
let element = element.clone();
|
|
|
@ -641,9 +757,13 @@ pub(super) fn insert<'a, T: Send + Clone + 'a>(element: T) |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_item_to_inventory(character: CharacterEntity)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>> + Clone
|
|
|
|
pub(super) fn add_item_to_inventory<EG, TR>(
|
|
|
|
character: CharacterEntity,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>> + Clone
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
let character = character.clone();
|
|
|
@ -658,16 +778,22 @@ pub(super) fn add_item_to_inventory(character: CharacterEntity) |
|
|
|
|
|
|
|
inventory.add_item(inventory_item.clone())?;
|
|
|
|
transaction.gateway().set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
|
|
|
item_state.set_inventory(inventory);
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
Ok(((item_state, transaction), inventory_item))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn record_trade(trade_id: TradeId, character_to: CharacterEntityId, character_from: CharacterEntityId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<InventoryItem>)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), Vec<InventoryItem>), ItemStateError>> + Send + 'a>> + Clone
|
|
|
|
pub(super) fn record_trade<EG, TR>(
|
|
|
|
trade_id: TradeId,
|
|
|
|
character_to: CharacterEntityId,
|
|
|
|
character_from: CharacterEntityId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), Vec<InventoryItem>)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), Vec<InventoryItem>), ItemStateError>> + Send>> + Clone
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(item_state, mut transaction), traded_items| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -688,9 +814,12 @@ pub(super) fn record_trade(trade_id: TradeId, character_to: CharacterEntityId, c |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn assign_new_item_id()
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>> + Clone
|
|
|
|
pub(super) fn assign_new_item_id<EG, TR>(
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>> + Clone
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), mut inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -701,9 +830,14 @@ pub(super) fn assign_new_item_id() |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn convert_item_drop_to_floor_item(character_id: CharacterEntityId, item_drop: ItemDrop)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem), ItemStateError>> + Send + 'a>> + Clone
|
|
|
|
pub(super) fn convert_item_drop_to_floor_item<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
item_drop: ItemDrop,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), ())
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), FloorItem), ItemStateError>> + Send>> + Clone
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, mut transaction), _| {
|
|
|
|
let item_drop = item_drop.clone();
|
|
|
@ -798,9 +932,13 @@ pub(super) fn convert_item_drop_to_floor_item(character_id: CharacterEntityId, i |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn add_item_to_local_floor(character_id: CharacterEntityId)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), FloorItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn add_item_to_local_floor<EG, TR>(
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), FloorItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(mut item_state, transaction) , floor_item| {
|
|
|
|
Box::pin(async move {
|
|
|
@ -813,9 +951,13 @@ pub(super) fn add_item_to_local_floor(character_id: CharacterEntityId) |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn apply_modifier_to_inventory_item(modifier: ItemModifier)
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn apply_modifier_to_inventory_item<EG, TR>(
|
|
|
|
modifier: ItemModifier,
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), InventoryItem), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(item_state, mut transaction), mut inventory_item| {
|
|
|
|
let modifier = modifier.clone();
|
|
|
@ -833,9 +975,12 @@ pub(super) fn apply_modifier_to_inventory_item(modifier: ItemModifier) |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(super) fn as_individual_item()
|
|
|
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), IndividualItemDetail), ItemStateError>> + Send + 'a>>
|
|
|
|
pub(super) fn as_individual_item<EG, TR>(
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), InventoryItem)
|
|
|
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, TR), IndividualItemDetail), ItemStateError>> + Send>>
|
|
|
|
where
|
|
|
|
EG: EntityGateway,
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'static,
|
|
|
|
{
|
|
|
|
move |(item_state, transaction), inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
|