|
|
@ -7,6 +7,8 @@ use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms, ItemShops}; |
|
|
|
use crate::ship::location::{ClientLocation, ClientLocationError};
|
|
|
|
use crate::ship::drops::ItemDrop;
|
|
|
|
use crate::ship::items::{ItemManager, ClientItemId, TriggerCreateItem, FloorItem};
|
|
|
|
// use crate::ship::items::bank::{BANK_MESETA_CAPACITY}; // compiler error: private module
|
|
|
|
// use crate::ship::items::inventory::{INVENTORY_MESETA_CAPACITY}; // compiler error: private module
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
use libpso::utf8_to_utf16_array;
|
|
|
|
use crate::ship::packet::builder;
|
|
|
@ -19,6 +21,9 @@ const SHOP_OPTION_TOOL: u8 = 0; |
|
|
|
const SHOP_OPTION_WEAPON: u8 = 1;
|
|
|
|
const SHOP_OPTION_ARMOR: u8 = 2;
|
|
|
|
|
|
|
|
const INVENTORY_MESETA_CAPACITY: u32 = 999999;
|
|
|
|
const BANK_MESETA_CAPACITY: u32 = 999999;
|
|
|
|
|
|
|
|
//const BANK_ACTION_: u8 = 1;
|
|
|
|
|
|
|
|
fn send_to_client(id: ClientId, target: u8, msg: DirectMessage, client_location: &ClientLocation)
|
|
|
@ -213,10 +218,11 @@ pub async fn send_bank_list(id: ClientId, |
|
|
|
let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
let bank_items = item_manager.get_character_bank(&client.character)?;
|
|
|
|
|
|
|
|
let bank_items_pkt = builder::message::bank_item_list(&bank_items);
|
|
|
|
let bank_items_pkt = builder::message::bank_item_list(&bank_items, client.character.bank_meseta);
|
|
|
|
Ok(Box::new(vec![(id, SendShipPacket::BankItemList(bank_items_pkt))].into_iter()))
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: error if too much money is deposited/withdrawn
|
|
|
|
pub async fn bank_interaction<EG>(id: ClientId,
|
|
|
|
bank_interaction: &BankInteraction,
|
|
|
|
entity_gateway: &mut EG,
|
|
|
@ -233,11 +239,11 @@ where |
|
|
|
let bank_action_pkts = match bank_interaction.action {
|
|
|
|
BANK_ACTION_DEPOSIT => {
|
|
|
|
if bank_interaction.item_id == 0xFFFFFFFF {
|
|
|
|
if client.character.meseta > bank_interaction.meseta_amount && (bank_interaction.meseta_amount + client.character.bank_meseta) <= 999999 {
|
|
|
|
if client.character.meseta >= bank_interaction.meseta_amount && (bank_interaction.meseta_amount + client.character.bank_meseta) <= BANK_MESETA_CAPACITY {
|
|
|
|
client.character.meseta -= bank_interaction.meseta_amount;
|
|
|
|
client.character.bank_meseta += bank_interaction.meseta_amount;
|
|
|
|
entity_gateway.save_character(&client.character).await?;
|
|
|
|
}
|
|
|
|
} /* else {error deposited too much money} */
|
|
|
|
Vec::new()
|
|
|
|
}
|
|
|
|
else {
|
|
|
@ -248,11 +254,11 @@ where |
|
|
|
},
|
|
|
|
BANK_ACTION_WITHDRAW => {
|
|
|
|
if bank_interaction.item_id == 0xFFFFFFFF {
|
|
|
|
if client.character.meseta + bank_interaction.meseta_amount <= 999999 {
|
|
|
|
if client.character.meseta + bank_interaction.meseta_amount <= INVENTORY_MESETA_CAPACITY {
|
|
|
|
client.character.meseta += bank_interaction.meseta_amount;
|
|
|
|
client.character.bank_meseta -= bank_interaction.meseta_amount;
|
|
|
|
entity_gateway.save_character(&client.character).await?;
|
|
|
|
}
|
|
|
|
} /* else {error withdrew too much money} */
|
|
|
|
Vec::new()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|