|
@ -15,7 +15,7 @@ use libpso::utf8_to_utf16_array; |
|
|
use crate::ship::packet::builder;
|
|
|
use crate::ship::packet::builder;
|
|
|
use crate::ship::shops::{ShopItem, ToolShopItem, ArmorShopItem};
|
|
|
use crate::ship::shops::{ShopItem, ToolShopItem, ArmorShopItem};
|
|
|
use crate::ship::items::state::{ItemState, FloorType, FloorItemDetail};
|
|
|
use crate::ship::items::state::{ItemState, FloorType, FloorItemDetail};
|
|
|
use crate::ship::items::actions::{pick_up_item, withdraw_meseta, deposit_meseta, withdraw_item, deposit_item, buy_shop_item, enemy_drops_item, TriggerCreateItem};
|
|
|
|
|
|
|
|
|
use crate::ship::items::actions::{pick_up_item, withdraw_meseta, deposit_meseta, withdraw_item, deposit_item, buy_shop_item, enemy_drops_item, take_meseta, apply_modifier, TriggerCreateItem};
|
|
|
|
|
|
|
|
|
const BANK_ACTION_DEPOSIT: u8 = 0;
|
|
|
const BANK_ACTION_DEPOSIT: u8 = 0;
|
|
|
const BANK_ACTION_WITHDRAW: u8 = 1;
|
|
|
const BANK_ACTION_WITHDRAW: u8 = 1;
|
|
@ -151,7 +151,7 @@ where |
|
|
let (item, floor_type) = item_state.get_floor_item(&client.character.id, &ClientItemId(pickup_item.item_id))?;
|
|
|
let (item, floor_type) = item_state.get_floor_item(&client.character.id, &ClientItemId(pickup_item.item_id))?;
|
|
|
let remove_item = builder::message::remove_item_from_floor(area_client, item)?;
|
|
|
let remove_item = builder::message::remove_item_from_floor(area_client, item)?;
|
|
|
let create_item = match &item.item {
|
|
|
let create_item = match &item.item {
|
|
|
FloorItemDetail::Individual(individual_floor_item) => Some(builder::message::create_individual_item(area_client, item.item_id, &individual_floor_item.item)?),
|
|
|
|
|
|
|
|
|
FloorItemDetail::Individual(individual_floor_item) => Some(builder::message::create_individual_item(area_client, item.item_id, individual_floor_item)?),
|
|
|
FloorItemDetail::Stacked(stacked_floor_item) => Some(builder::message::create_stacked_item(area_client, item.item_id, &stacked_floor_item.tool, stacked_floor_item.count())?),
|
|
|
FloorItemDetail::Stacked(stacked_floor_item) => Some(builder::message::create_stacked_item(area_client, item.item_id, &stacked_floor_item.tool, stacked_floor_item.count())?),
|
|
|
FloorItemDetail::Meseta(_) => None,
|
|
|
FloorItemDetail::Meseta(_) => None,
|
|
|
//_ => Some(builder::message::create_item(area_client, &item)?),
|
|
|
//_ => Some(builder::message::create_item(area_client, &item)?),
|
|
@ -411,7 +411,7 @@ pub async fn request_tek_item<EG>(id: ClientId, |
|
|
tek_request: &TekRequest,
|
|
|
tek_request: &TekRequest,
|
|
|
entity_gateway: &mut EG,
|
|
|
entity_gateway: &mut EG,
|
|
|
clients: &mut Clients,
|
|
|
clients: &mut Clients,
|
|
|
item_manager: &mut ItemManager)
|
|
|
|
|
|
|
|
|
item_state: &mut ItemState)
|
|
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error>
|
|
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error>
|
|
|
where
|
|
|
where
|
|
|
EG: EntityGateway
|
|
|
EG: EntityGateway
|
|
@ -429,13 +429,14 @@ where |
|
|
|
|
|
|
|
|
client.tek = Some((ClientItemId(tek_request.item_id), special_mod, percent_mod, grind_mod));
|
|
|
client.tek = Some((ClientItemId(tek_request.item_id), special_mod, percent_mod, grind_mod));
|
|
|
|
|
|
|
|
|
let inventory = item_manager.get_character_inventory(&client.character)?;
|
|
|
|
|
|
let item = inventory.get_item_by_id(ClientItemId(tek_request.item_id))
|
|
|
|
|
|
|
|
|
let inventory = item_state.get_character_inventory(&client.character)?;
|
|
|
|
|
|
let item = inventory.get_by_client_id(&ClientItemId(tek_request.item_id))
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
|
|
let mut weapon = *item.individual()
|
|
|
|
|
|
|
|
|
let mut weapon = item.item.as_individual()
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
|
|
.weapon()
|
|
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
|
|
|
|
|
|
|
|
.as_weapon()
|
|
|
|
|
|
.ok_or(ItemManagerError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
|
|
|
|
|
.clone();
|
|
|
|
|
|
|
|
|
weapon.apply_modifier(&item::weapon::WeaponModifier::Tekked {
|
|
|
weapon.apply_modifier(&item::weapon::WeaponModifier::Tekked {
|
|
|
special: special_mod,
|
|
|
special: special_mod,
|
|
@ -443,9 +444,7 @@ where |
|
|
grind: grind_mod,
|
|
|
grind: grind_mod,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
let character_meseta = item_manager.get_character_meseta_mut(&client.character.id)?;
|
|
|
|
|
|
character_meseta.0 -= 100;
|
|
|
|
|
|
entity_gateway.set_character_meseta(&client.character.id, *character_meseta).await?;
|
|
|
|
|
|
|
|
|
take_meseta(item_state, entity_gateway, &client.character.id, item::Meseta(100)).await?;
|
|
|
|
|
|
|
|
|
let preview_pkt = builder::message::tek_preview(ClientItemId(tek_request.item_id), &weapon)?;
|
|
|
let preview_pkt = builder::message::tek_preview(ClientItemId(tek_request.item_id), &weapon)?;
|
|
|
|
|
|
|
|
@ -457,7 +456,7 @@ pub async fn accept_tek_item<EG>(id: ClientId, |
|
|
entity_gateway: &mut EG,
|
|
|
entity_gateway: &mut EG,
|
|
|
client_location: &ClientLocation,
|
|
|
client_location: &ClientLocation,
|
|
|
clients: &mut Clients,
|
|
|
clients: &mut Clients,
|
|
|
item_manager: &mut ItemManager)
|
|
|
|
|
|
|
|
|
item_state: &mut ItemState)
|
|
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error>
|
|
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error>
|
|
|
where
|
|
|
where
|
|
|
EG: EntityGateway
|
|
|
EG: EntityGateway
|
|
@ -475,9 +474,9 @@ where |
|
|
percent: percent_mod,
|
|
|
percent: percent_mod,
|
|
|
grind: grind_mod,
|
|
|
grind: grind_mod,
|
|
|
};
|
|
|
};
|
|
|
let weapon = item_manager.replace_item_with_tekked(entity_gateway, &client.character, item_id, modifier).await?;
|
|
|
|
|
|
|
|
|
let weapon = apply_modifier(item_state, entity_gateway, &client.character, item_id, item::ItemModifier::WeaponModifier(modifier)).await?;
|
|
|
|
|
|
|
|
|
let create_item_pkt = builder::message::create_individual_item(area_client, item_id, &item::ItemDetail::Weapon(weapon))?;
|
|
|
|
|
|
|
|
|
let create_item_pkt = builder::message::create_individual_item(area_client, item_id, &weapon)?;
|
|
|
|
|
|
|
|
|
let neighbors = client_location.get_client_neighbors(id).map_err(|err| -> ClientLocationError { err.into() })?;
|
|
|
let neighbors = client_location.get_client_neighbors(id).map_err(|err| -> ClientLocationError { err.into() })?;
|
|
|
Ok(Box::new(neighbors.into_iter()
|
|
|
Ok(Box::new(neighbors.into_iter()
|
|
|