You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.3 KiB
68 lines
1.3 KiB
//! Network formats and container messages
|
|
|
|
mod action;
|
|
pub use action::*;
|
|
|
|
mod req;
|
|
pub use req::*;
|
|
|
|
mod resp;
|
|
pub use resp::*;
|
|
|
|
mod update;
|
|
pub use update::*;
|
|
|
|
use crate::{
|
|
data::{Color, Player},
|
|
map::Map,
|
|
Id,
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// An alias for a User's ID
|
|
pub type UserId = usize;
|
|
|
|
/// Represents a user payload
|
|
#[derive(Copy, Clone, Serialize, Deserialize)]
|
|
pub struct User {
|
|
/// The internal user ID
|
|
pub id: UserId,
|
|
/// The auth token provided by the client
|
|
pub token: Id,
|
|
/// Whether the scores will be tracked
|
|
pub registered: bool,
|
|
}
|
|
|
|
/// A more lobby specific abstraction for a user
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
pub struct LobbyUser {
|
|
/// The user ID
|
|
pub id: UserId,
|
|
/// Their nick name
|
|
pub name: String,
|
|
/// Are they ready?
|
|
pub ready: bool,
|
|
/// Are they the lobby admin?
|
|
pub admin: bool,
|
|
/// The colour they will be in the match
|
|
pub color: Color,
|
|
}
|
|
|
|
/// An alias for a Room ID
|
|
pub type LobbyId = usize;
|
|
|
|
/// Represent a lobby
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
pub struct Lobby {
|
|
/// The ID of the lobby
|
|
pub id: LobbyId,
|
|
/// A set of user IDs
|
|
pub players: Vec<LobbyUser>,
|
|
/// The name of the map
|
|
pub map: String,
|
|
/// Settings
|
|
pub settings: Vec<String>,
|
|
}
|
|
|
|
/// An alias for a match ID
|
|
pub type MatchId = usize;
|
|
|