|
@ -9,22 +9,23 @@ use std::iter::IntoIterator; |
|
|
use anyhow::Context;
|
|
|
use anyhow::Context;
|
|
|
|
|
|
|
|
|
use libpso::packet::{ship::Message, messages::GameMessage};
|
|
|
use libpso::packet::{ship::Message, messages::GameMessage};
|
|
|
use crate::ship::map::MapArea;
|
|
|
|
|
|
use crate::ship::ship::SendShipPacket;
|
|
|
|
|
|
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
|
|
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
|
|
use crate::entity::gateway::{EntityGateway, EntityGatewayTransaction};
|
|
|
use crate::entity::gateway::{EntityGateway, EntityGatewayTransaction};
|
|
|
|
|
|
use crate::entity::item::{ItemDetail, NewItemEntity, TradeId, ItemModifier};
|
|
|
|
|
|
use crate::entity::item::tool::Tool;
|
|
|
|
|
|
use crate::entity::room::RoomEntityId;
|
|
|
|
|
|
use crate::ship::map::MapArea;
|
|
|
|
|
|
use crate::ship::ship::SendShipPacket;
|
|
|
use crate::ship::items::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail};
|
|
|
use crate::ship::items::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail};
|
|
|
use crate::ship::items::bank::{BankItem, BankItemDetail};
|
|
|
use crate::ship::items::bank::{BankItem, BankItemDetail};
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
use crate::ship::items::floor::{FloorItem, FloorItemDetail};
|
|
|
use crate::ship::items::floor::{FloorItem, FloorItemDetail};
|
|
|
use crate::ship::items::apply_item::{apply_item, ApplyItemAction};
|
|
|
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;
|
|
|
|
|
|
use crate::ship::shops::ShopItem;
|
|
|
use crate::ship::shops::ShopItem;
|
|
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
|
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
|
|
use crate::ship::packet::builder;
|
|
|
use crate::ship::packet::builder;
|
|
|
use crate::ship::location::AreaClient;
|
|
|
use crate::ship::location::AreaClient;
|
|
|
|
|
|
use crate::ship::monster::MonsterType;
|
|
|
|
|
|
|
|
|
pub enum TriggerCreateItem {
|
|
|
pub enum TriggerCreateItem {
|
|
|
Yes,
|
|
|
Yes,
|
|
@ -513,7 +514,9 @@ where |
|
|
Box::pin(async move {
|
|
|
Box::pin(async move {
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
async move {
|
|
|
async move {
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Consumed).await?;
|
|
|
|
|
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Consumed {
|
|
|
|
|
|
character_id: character.id,
|
|
|
|
|
|
}).await?;
|
|
|
Ok(transaction)
|
|
|
Ok(transaction)
|
|
|
}}).await?;
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
@ -660,7 +663,9 @@ where |
|
|
|
|
|
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
async move {
|
|
|
async move {
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::SoldToShop).await?;
|
|
|
|
|
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::SoldToShop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
}).await?;
|
|
|
Ok(transaction)
|
|
|
Ok(transaction)
|
|
|
}}).await?;
|
|
|
}}).await?;
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
|
transaction.gateway().set_character_meseta(&character_id, inventory.meseta).await?;
|
|
@ -946,13 +951,6 @@ where |
|
|
let entity = transaction.gateway().create_item(NewItemEntity {
|
|
|
let entity = transaction.gateway().create_item(NewItemEntity {
|
|
|
item: item_detail.clone(),
|
|
|
item: item_detail.clone(),
|
|
|
}).await?;
|
|
|
}).await?;
|
|
|
transaction.gateway().add_item_note(&entity.id, ItemNote::EnemyDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
map_area: item_drop.map_area,
|
|
|
|
|
|
x: item_drop.x,
|
|
|
|
|
|
y: item_drop.y,
|
|
|
|
|
|
z: item_drop.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
FloorItem {
|
|
|
FloorItem {
|
|
|
item_id,
|
|
|
item_id,
|
|
|
item: FloorItemDetail::Individual(IndividualItemDetail {
|
|
|
item: FloorItemDetail::Individual(IndividualItemDetail {
|
|
@ -969,13 +967,6 @@ where |
|
|
let entity = transaction.gateway().create_item(NewItemEntity {
|
|
|
let entity = transaction.gateway().create_item(NewItemEntity {
|
|
|
item: ItemDetail::Tool(tool),
|
|
|
item: ItemDetail::Tool(tool),
|
|
|
}).await?;
|
|
|
}).await?;
|
|
|
transaction.gateway().add_item_note(&entity.id, ItemNote::EnemyDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
map_area: item_drop.map_area,
|
|
|
|
|
|
x: item_drop.x,
|
|
|
|
|
|
y: item_drop.y,
|
|
|
|
|
|
z: item_drop.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
FloorItem {
|
|
|
FloorItem {
|
|
|
item_id,
|
|
|
item_id,
|
|
|
item: FloorItemDetail::Stacked(StackedItemDetail{
|
|
|
item: FloorItemDetail::Stacked(StackedItemDetail{
|
|
@ -1005,6 +996,88 @@ where |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn item_note_enemy_drop<'a, EG, TR>(
|
|
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
|
|
room_id: RoomEntityId,
|
|
|
|
|
|
monster_type: MonsterType,
|
|
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|
|
|
|
-> BoxFuture<'a, Result<((ItemStateProxy, TR), FloorItem), anyhow::Error>> + Clone
|
|
|
|
|
|
where
|
|
|
|
|
|
EG: EntityGateway,
|
|
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'a,
|
|
|
|
|
|
{
|
|
|
|
|
|
move |(item_state, mut transaction), floor_item| {
|
|
|
|
|
|
Box::pin(async move {
|
|
|
|
|
|
match &floor_item.item {
|
|
|
|
|
|
FloorItemDetail::Individual(individual) => {
|
|
|
|
|
|
transaction.gateway().add_item_note(&individual.entity_id, ItemNote::EnemyDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
room_id,
|
|
|
|
|
|
monster_type,
|
|
|
|
|
|
map_area: floor_item.map_area,
|
|
|
|
|
|
x: floor_item.x,
|
|
|
|
|
|
y: floor_item.y,
|
|
|
|
|
|
z: floor_item.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
},
|
|
|
|
|
|
FloorItemDetail::Stacked(stacked) => {
|
|
|
|
|
|
transaction.gateway().add_item_note(&stacked.entity_ids[0], ItemNote::EnemyDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
room_id,
|
|
|
|
|
|
monster_type,
|
|
|
|
|
|
map_area: floor_item.map_area,
|
|
|
|
|
|
x: floor_item.x,
|
|
|
|
|
|
y: floor_item.y,
|
|
|
|
|
|
z: floor_item.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
},
|
|
|
|
|
|
_ => {},
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(((item_state, transaction), floor_item))
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn item_note_box_drop<'a, EG, TR>(
|
|
|
|
|
|
character_id: CharacterEntityId,
|
|
|
|
|
|
room_id: RoomEntityId,
|
|
|
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|
|
|
|
-> BoxFuture<'a, Result<((ItemStateProxy, TR), FloorItem), anyhow::Error>> + Clone
|
|
|
|
|
|
where
|
|
|
|
|
|
EG: EntityGateway,
|
|
|
|
|
|
TR: EntityGatewayTransaction<ParentGateway = EG> + 'a,
|
|
|
|
|
|
{
|
|
|
|
|
|
move |(item_state, mut transaction), floor_item| {
|
|
|
|
|
|
Box::pin(async move {
|
|
|
|
|
|
match &floor_item.item {
|
|
|
|
|
|
FloorItemDetail::Individual(individual) => {
|
|
|
|
|
|
transaction.gateway().add_item_note(&individual.entity_id, ItemNote::BoxDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
room_id,
|
|
|
|
|
|
map_area: floor_item.map_area,
|
|
|
|
|
|
x: floor_item.x,
|
|
|
|
|
|
y: floor_item.y,
|
|
|
|
|
|
z: floor_item.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
},
|
|
|
|
|
|
FloorItemDetail::Stacked(stacked) => {
|
|
|
|
|
|
transaction.gateway().add_item_note(&stacked.entity_ids[0], ItemNote::BoxDrop {
|
|
|
|
|
|
character_id,
|
|
|
|
|
|
room_id,
|
|
|
|
|
|
map_area: floor_item.map_area,
|
|
|
|
|
|
x: floor_item.x,
|
|
|
|
|
|
y: floor_item.y,
|
|
|
|
|
|
z: floor_item.z,
|
|
|
|
|
|
}).await?;
|
|
|
|
|
|
},
|
|
|
|
|
|
_ => {},
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(((item_state, transaction), floor_item))
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
pub(super) fn add_item_to_local_floor<'a, EG, TR>(
|
|
|
pub(super) fn add_item_to_local_floor<'a, EG, TR>(
|
|
|
character_id: CharacterEntityId,
|
|
|
character_id: CharacterEntityId,
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|
) -> impl Fn((ItemStateProxy, TR), FloorItem)
|
|
|