This commit is contained in:
		
							parent
							
								
									70c89cd9ad
								
							
						
					
					
						commit
						e349a41b16
					
				| @ -3,6 +3,7 @@ use serde::{Serialize, Deserialize}; | ||||
| use std::collections::HashMap; | ||||
| use thiserror::Error; | ||||
| use crate::ship::room::Episode; | ||||
| use std::fmt; | ||||
| 
 | ||||
| #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] | ||||
| pub enum MapArea { | ||||
| @ -256,6 +257,60 @@ impl MapArea { | ||||
|             MapArea::SaintMillion => Episode::Four, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn as_string(&self) -> &str{ | ||||
|         match self { | ||||
|             MapArea::Pioneer2Ep1 => "Pioneer 2", | ||||
|             MapArea::Forest1 => "Forest 1", | ||||
|             MapArea::Forest2 => "Forest 2", | ||||
|             MapArea::Caves1 => "Caves 1", | ||||
|             MapArea::Caves2 => "Caves 2", | ||||
|             MapArea::Caves3 => "Caves 3", | ||||
|             MapArea::Mines1 => "Mines 1", | ||||
|             MapArea::Mines2 => "Mines 2", | ||||
|             MapArea::Ruins1 => "Ruins 1", | ||||
|             MapArea::Ruins2 => "Ruins 2", | ||||
|             MapArea::Ruins3 => "Ruins 3", | ||||
|             MapArea::Dragon => "Dragon", | ||||
|             MapArea::DeRolLe => "De Rol Le", | ||||
|             MapArea::VolOpt => "Vol Opt", | ||||
|             MapArea::DarkFalz => "Dark Falz", | ||||
|             MapArea::Pioneer2Ep2 => "Pioneer 2", | ||||
|             MapArea::VrTempleAlpha => "Vr Temple Alpha", | ||||
|             MapArea::VrTempleBeta => "Vr Temple Beta", | ||||
|             MapArea::VrSpaceshipAlpha => "Vr Spaceship Alpha", | ||||
|             MapArea::VrSpaceshipBeta => "Vr Spaceship Beta", | ||||
|             MapArea::Cca => "CCA", | ||||
|             MapArea::JungleAreaNorth => "Jungle Area North", | ||||
|             MapArea::JungleAreaEast => "Jungle Area East", | ||||
|             MapArea::Mountain => "Mountain", | ||||
|             MapArea::Seaside => "Seaside", | ||||
|             MapArea::SeabedUpper => "Seabed Upper", | ||||
|             MapArea::SeabedLower => "Seabed Lower", | ||||
|             MapArea::GalGryphon => "Gal Gryphon", | ||||
|             MapArea::OlgaFlow => "Olga Flow", | ||||
|             MapArea::BarbaRay => "Barba Ray", | ||||
|             MapArea::GolDragon => "Gol Dragon", | ||||
|             MapArea::SeasideNight => "Seaside Night", | ||||
|             MapArea::Tower => "Tower", | ||||
|             MapArea::Pioneer2Ep4 => "Pioneer 2", | ||||
|             MapArea::CraterEast => "Crater East", | ||||
|             MapArea::CraterWest => "Crater West", | ||||
|             MapArea::CraterSouth => "Crater South", | ||||
|             MapArea::CraterNorth => "Crater North", | ||||
|             MapArea::CraterInterior => "Crater Interior", | ||||
|             MapArea::SubDesert1 => "Sub Desert 1", | ||||
|             MapArea::SubDesert2 => "Sub Desert 2", | ||||
|             MapArea::SubDesert3 => "Sub Desert 3", | ||||
|             MapArea::SaintMillion => "Saint Million", | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl fmt::Display for MapArea { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|         write!(f, "{}", self.as_string()) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -3,11 +3,11 @@ use crate::common::serverstate::ClientId; | ||||
| use crate::common::leveltable::CharacterLevelTable; | ||||
| use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms}; | ||||
| use crate::ship::character::{FullCharacterBytesBuilder}; | ||||
| use crate::ship::location::{ClientLocation, LobbyId, RoomLobby, ClientLocationError}; | ||||
| //use crate::ship::items::;
 | ||||
| use crate::ship::location::{ClientLocation, LobbyId, RoomLobby, ClientLocationError, RoomId}; | ||||
| use crate::ship::packet; | ||||
| use crate::ship::items::ItemManager; | ||||
| use crate::entity::gateway::EntityGateway; | ||||
| use crate::ship::map::MapArea; | ||||
| 
 | ||||
| // this function needs a better home
 | ||||
| pub fn block_selected(id: ClientId, | ||||
| @ -130,3 +130,25 @@ pub fn remove_from_lobby(id: ClientId, | ||||
|         (n.client, leave_lobby_pkt.clone()) | ||||
|     }).collect()) | ||||
| } | ||||
| 
 | ||||
| pub fn get_room_tab_info(id: ClientId, | ||||
|                                 pkt: &MenuDetail, | ||||
|                                 client_location: &mut ClientLocation, | ||||
|                                 clients: &Clients) | ||||
|                                 -> Result<Vec<(ClientId, SendShipPacket)>, anyhow::Error> { | ||||
|     let room_id = RoomId(pkt.item as usize); | ||||
|     let clients_in_room = client_location.get_clients_in_room(room_id).map_err(|err| -> ClientLocationError { err.into() })?; | ||||
|     let mut room_info = String::new(); | ||||
|     for client in clients_in_room { | ||||
|         let cs = clients.get(&client.client).ok_or(ShipError::ClientNotFound(client.client))?; | ||||
|         let gc = cs.user.guildcard; | ||||
|         let name = &cs.character.name; | ||||
|         let cls = cs.character.char_class; | ||||
|         let leveltable = CharacterLevelTable::default(); | ||||
|         let lv = leveltable.get_level_from_exp(cls, cs.character.exp); | ||||
|         let floor = cs.area.unwrap_or(MapArea::Pioneer2Ep1); | ||||
| 
 | ||||
|         room_info += format!("{} Lv{} {}\n{} {}\n", gc,lv,name,cls,floor).as_str(); | ||||
|     } | ||||
|     Ok(vec![(id, SendShipPacket::SmallLeftDialog(SmallLeftDialog::new(room_info)))]) | ||||
| } | ||||
| @ -178,6 +178,7 @@ pub enum SendShipPacket { | ||||
|     DirectMessage(DirectMessage), | ||||
|     PlayerChat(PlayerChat), | ||||
|     SmallDialog(SmallDialog), | ||||
|     SmallLeftDialog(SmallLeftDialog), | ||||
|     JoinRoom(JoinRoom), | ||||
|     AddToRoom(AddToRoom), | ||||
|     LeaveLobby(LeaveLobby), | ||||
| @ -219,6 +220,7 @@ impl SendServerPacket for SendShipPacket { | ||||
|             SendShipPacket::DirectMessage(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::PlayerChat(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::SmallDialog(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::SmallLeftDialog(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::JoinRoom(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::AddToRoom(pkt) => pkt.as_bytes(), | ||||
|             SendShipPacket::LeaveLobby(pkt) => pkt.as_bytes(), | ||||
| @ -636,9 +638,9 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { | ||||
|                 let block = self.blocks.with_client(id, &self.clients)?; | ||||
|                 handler::quest::player_chose_quest(id, questmenuselect, &mut self.clients, &block.client_location, &mut block.rooms)? | ||||
|             }, | ||||
|             RecvShipPacket::MenuDetail(_menudetail) => { | ||||
|                 //unreachable!();
 | ||||
|                 Box::new(Vec::new().into_iter()) | ||||
|             RecvShipPacket::MenuDetail(menudetail) => { | ||||
|                 let block = self.blocks.with_client(id, &self.clients)?; | ||||
|                 Box::new(handler::lobby::get_room_tab_info(id, menudetail, &mut block.client_location, &mut self.clients)?.into_iter()) | ||||
|             }, | ||||
|             RecvShipPacket::RoomPasswordReq(room_password_req) => { | ||||
|                 let block = self.blocks.with_client(id, &self.clients)?; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user