|
|
@ -15,7 +15,7 @@ pub fn block_selected(id: ClientId, |
|
|
|
clients: &mut Clients,
|
|
|
|
item_manager: &ItemManager,
|
|
|
|
level_table: &CharacterLevelTable)
|
|
|
|
-> Result<Vec<SendShipPacket>, anyhow::Error> {
|
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, anyhow::Error> {
|
|
|
|
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
client.block = pkt.item as usize - 1;
|
|
|
|
|
|
|
@ -38,11 +38,11 @@ pub fn block_selected(id: ClientId, |
|
|
|
.build();
|
|
|
|
|
|
|
|
Ok(vec![
|
|
|
|
SendShipPacket::FullCharacter(Box::new(FullCharacter {
|
|
|
|
(id, SendShipPacket::FullCharacter(Box::new(FullCharacter {
|
|
|
|
character: fc,
|
|
|
|
})),
|
|
|
|
SendShipPacket::CharDataRequest(CharDataRequest {}),
|
|
|
|
SendShipPacket::LobbyList(LobbyList::new()),
|
|
|
|
}))),
|
|
|
|
(id, SendShipPacket::CharDataRequest(CharDataRequest {})),
|
|
|
|
(id, SendShipPacket::LobbyList(LobbyList::new())),
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
@ -113,3 +113,17 @@ pub async fn change_lobby<EG: EntityGateway>(id: ClientId, |
|
|
|
.map(|c| (c.client, SendShipPacket::LeaveLobby(leave_lobby.clone()))))
|
|
|
|
.collect())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn remove_from_lobby(id: ClientId,
|
|
|
|
client_location: &mut ClientLocation)
|
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, anyhow::Error> {
|
|
|
|
let area_client = client_location.get_local_client(id)?;
|
|
|
|
let neighbors = client_location.get_client_neighbors(id)?;
|
|
|
|
let leader = client_location.get_leader_by_client(id)?;
|
|
|
|
let leave_lobby_pkt = SendShipPacket::LeaveLobby(LeaveLobby::new(area_client.local_client.id(), leader.local_client.id()));
|
|
|
|
|
|
|
|
client_location.remove_client_from_area(id)?;
|
|
|
|
Ok(neighbors.into_iter().map(|n| {
|
|
|
|
(n.client, leave_lobby_pkt.clone())
|
|
|
|
}).collect())
|
|
|
|
}
|