|
|
@ -45,23 +45,19 @@ fn add_floor_item_to_inventory(character: &CharacterEntity) |
|
|
|
let mut inventory = item_state.inventory(&character.id)?;
|
|
|
|
|
|
|
|
let character_id = character.id;
|
|
|
|
let transaction = floor_item.with_entity_id(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id| {
|
|
|
|
let transaction = floor_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Pickup {
|
|
|
|
character_id
|
|
|
|
}).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Pickup {
|
|
|
|
character_id
|
|
|
|
}).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
let mut transaction = floor_item.with_mag(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id, _mag| {
|
|
|
|
let mut transaction = floor_item.with_mag(transaction, |mut transaction, entity_id, _mag| {
|
|
|
|
let character = character.clone();
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().change_mag_owner(&entity_id, &character).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().change_mag_owner(&entity_id, &character).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
let add_result = inventory.add_floor_item(floor_item)?;
|
|
|
@ -125,18 +121,16 @@ fn add_inventory_item_to_shared_floor(character_id: CharacterEntityId, map_area: |
|
|
|
{
|
|
|
|
move |(mut item_state, transaction), inventory_item| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let transaction = inventory_item.with_entity_id(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id| {
|
|
|
|
let transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::PlayerDrop {
|
|
|
|
character_id,
|
|
|
|
map_area,
|
|
|
|
x: drop_position.0,
|
|
|
|
y: drop_position.1,
|
|
|
|
z: drop_position.2,
|
|
|
|
}).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::PlayerDrop {
|
|
|
|
character_id,
|
|
|
|
map_area,
|
|
|
|
x: drop_position.0,
|
|
|
|
y: drop_position.1,
|
|
|
|
z: drop_position.2,
|
|
|
|
}).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
let mut floor = item_state.floor(&character_id)?;
|
|
|
@ -376,16 +370,14 @@ fn add_bank_item_to_inventory(character: &CharacterEntity) |
|
|
|
let mut inventory = item_state.inventory(&character.id)?;
|
|
|
|
|
|
|
|
let character_id = character.id;
|
|
|
|
let transaction = bank_item.with_entity_id(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id| {
|
|
|
|
let transaction = bank_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
|
let bank_name = bank_name.clone();
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Withdraw {
|
|
|
|
character_id,
|
|
|
|
bank: bank_name,
|
|
|
|
}).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Withdraw {
|
|
|
|
character_id,
|
|
|
|
bank: bank_name,
|
|
|
|
}).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
let inventory_item = InventoryItem {
|
|
|
@ -396,13 +388,11 @@ fn add_bank_item_to_inventory(character: &CharacterEntity) |
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut transaction = inventory_item.with_mag(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id, _mag| {
|
|
|
|
let mut transaction = inventory_item.with_mag(transaction, |mut transaction, entity_id, _mag| {
|
|
|
|
let character = character.clone();
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().change_mag_owner(&entity_id, &character).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().change_mag_owner(&entity_id, &character).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
inventory.add_item(inventory_item.clone())?;
|
|
|
@ -444,16 +434,14 @@ fn add_inventory_item_to_bank(character_id: CharacterEntityId) |
|
|
|
Box::pin(async move {
|
|
|
|
let mut bank = item_state.bank(&character_id)?;
|
|
|
|
let bank_name = bank.name.clone();
|
|
|
|
let mut transaction = inventory_item.with_entity_id(Ok(transaction), move |mut transaction: Result<_, ItemStateError>, entity_id| {
|
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, move |mut transaction, entity_id| {
|
|
|
|
let bank_name = bank_name.clone();
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Deposit {
|
|
|
|
character_id,
|
|
|
|
bank: bank_name,
|
|
|
|
}).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Deposit {
|
|
|
|
character_id,
|
|
|
|
bank: bank_name,
|
|
|
|
}).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
bank.add_inventory_item(inventory_item)?;
|
|
|
@ -609,12 +597,10 @@ fn use_consumed_item(character: CharacterEntity) |
|
|
|
move |(mut item_state, mut transaction), inventory_item| {
|
|
|
|
let mut character = character.clone();
|
|
|
|
Box::pin(async move {
|
|
|
|
let mut transaction = inventory_item.with_entity_id(Ok(transaction), |mut transaction: Result<_, ItemStateError>, entity_id| {
|
|
|
|
let mut transaction = inventory_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
|
|
async move {
|
|
|
|
if let Ok(transaction) = &mut transaction {
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Consumed).await?;
|
|
|
|
}
|
|
|
|
transaction
|
|
|
|
transaction.gateway().add_item_note(&entity_id, ItemNote::Consumed).await?;
|
|
|
|
Ok(transaction)
|
|
|
|
}}).await?;
|
|
|
|
|
|
|
|
apply_item(&mut item_state, transaction.gateway(), &mut character, inventory_item).await?;
|
|
|
|