|
|
@ -7,12 +7,13 @@ use libpso::packet::ship::*; |
|
|
|
use libpso::packet::messages::*;
|
|
|
|
use crate::common::serverstate::ClientId;
|
|
|
|
use crate::common::leveltable::LEVEL_TABLE;
|
|
|
|
use crate::entity::character::SectionID;
|
|
|
|
use crate::ship::drops::DropTable;
|
|
|
|
use crate::ship::ship::{SendShipPacket, Clients, ShipEvent};
|
|
|
|
use crate::ship::room::Rooms;
|
|
|
|
use crate::ship::room::{Rooms, Episode, Difficulty, RoomState};
|
|
|
|
use crate::ship::map::MapBuilder;
|
|
|
|
use crate::ship::location::{ClientLocation, RoomId, RoomLobby, GetAreaError};
|
|
|
|
use crate::ship::packet::builder;
|
|
|
|
use crate::ship::room;
|
|
|
|
use crate::ship::items::state::ItemState;
|
|
|
|
|
|
|
|
pub async fn create_room(id: ClientId,
|
|
|
@ -22,19 +23,20 @@ pub async fn create_room(id: ClientId, |
|
|
|
item_state: &mut ItemState,
|
|
|
|
rooms: &Rooms,
|
|
|
|
map_builder: Arc<Box<dyn MapBuilder>>,
|
|
|
|
drop_table_builder: Arc<Box<dyn Fn(Episode, Difficulty, SectionID) -> DropTable + Send + Sync>>,
|
|
|
|
event: ShipEvent)
|
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, anyhow::Error> {
|
|
|
|
let level = clients.with(id, |client| Box::pin(async move {
|
|
|
|
LEVEL_TABLE.get_level_from_exp(client.character.char_class, client.character.exp)
|
|
|
|
})).await?;
|
|
|
|
match room::Difficulty::try_from(create_room.difficulty)? {
|
|
|
|
room::Difficulty::Ultimate if level < 80 => {
|
|
|
|
match Difficulty::try_from(create_room.difficulty)? {
|
|
|
|
Difficulty::Ultimate if level < 80 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 80 \nto create Ultimate rooms.".into())))])
|
|
|
|
},
|
|
|
|
room::Difficulty::VeryHard if level < 40 => {
|
|
|
|
Difficulty::VeryHard if level < 40 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 40 \nto create Very Hard rooms.".into())))])
|
|
|
|
},
|
|
|
|
room::Difficulty::Hard if level < 20 => {
|
|
|
|
Difficulty::Hard if level < 20 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 20 \nto create Hard rooms.".into())))])
|
|
|
|
},
|
|
|
|
_ => {},
|
|
|
@ -49,7 +51,7 @@ pub async fn create_room(id: ClientId, |
|
|
|
let mut item_state = item_state.clone();
|
|
|
|
Box::pin(async move {
|
|
|
|
item_state.add_character_to_room(room_id, &client.character, area_client).await;
|
|
|
|
let mut room = room::RoomState::from_create_room(&create_room, map_builder, client.character.section_id, event)?;
|
|
|
|
let mut room = RoomState::from_create_room(&create_room, map_builder, drop_table_builder, client.character.section_id, event)?;
|
|
|
|
room.bursting = true;
|
|
|
|
Ok::<_, anyhow::Error>(room)
|
|
|
|
})}).await??;
|
|
|
@ -107,13 +109,13 @@ pub async fn join_room(id: ClientId, |
|
|
|
})).await?;
|
|
|
|
|
|
|
|
match difficulty {
|
|
|
|
room::Difficulty::Ultimate if level < 80 => {
|
|
|
|
Difficulty::Ultimate if level < 80 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 80 \nto join Ultimate rooms.".into())))])
|
|
|
|
},
|
|
|
|
room::Difficulty::VeryHard if level < 40 => {
|
|
|
|
Difficulty::VeryHard if level < 40 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 40 \nto join Very Hard rooms.".into())))])
|
|
|
|
},
|
|
|
|
room::Difficulty::Hard if level < 20 => {
|
|
|
|
Difficulty::Hard if level < 20 => {
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("You must be at least level 20 \nto join Hard rooms.".into())))])
|
|
|
|
},
|
|
|
|
_ => {},
|
|
|
|