diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-03-22 19:44:26 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-03-22 19:44:26 +0100 |
commit | 22c18205bcb3702ddf60f41f77f6f06554202f35 (patch) | |
tree | 5f402722bbd767354e040179f0b4cd5ccb6b3899 /src/wire | |
parent | a55c5bded047e1e2c54f6e3f25c9b8e36e605110 (diff) |
Updating gameplay starting mechanics, adding quadtree to map
Diffstat (limited to 'src/wire')
-rw-r--r-- | src/wire/mod.rs | 23 | ||||
-rw-r--r-- | src/wire/resp.rs | 17 |
2 files changed, 16 insertions, 24 deletions
diff --git a/src/wire/mod.rs b/src/wire/mod.rs index bf8dea0e8131..b1c231b44580 100644 --- a/src/wire/mod.rs +++ b/src/wire/mod.rs @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; pub type UserId = usize; /// Represents a user payload -#[derive(Clone, Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub struct User { /// The internal user ID pub id: UserId, @@ -34,7 +34,7 @@ pub struct User { } /// A more lobby specific abstraction for a user -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct LobbyUser { /// The user ID pub id: UserId, @@ -42,6 +42,8 @@ pub struct LobbyUser { 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, } @@ -50,7 +52,7 @@ pub struct LobbyUser { pub type LobbyId = usize; /// Represent a lobby -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct Lobby { /// The ID of the lobby pub id: LobbyId, @@ -65,19 +67,4 @@ pub struct Lobby { /// An alias for a match ID pub type MatchId = usize; -/// Mapping users to a player in game -#[derive(Serialize, Deserialize)] -pub struct MatchUser { - pub user: User, - pub player: Player, -} -#[derive(Serialize, Deserialize)] -pub struct Match { - /// The match id - pub id: MatchId, - /// The list of active players - pub players: Vec<MatchUser>, - /// The active game map - pub map: Map, -} diff --git a/src/wire/resp.rs b/src/wire/resp.rs index b9f41fbe93e4..4812baf13e39 100644 --- a/src/wire/resp.rs +++ b/src/wire/resp.rs @@ -16,18 +16,17 @@ pub enum Response { /// Get a list of available <name-room> pairs Rooms(Vec<(String, LobbyId)>), /// A user joins a game lobby - Join(Result<Lobby, RoomErr>), + Join(Result<Lobby, LobbyErr>), /// A user leaves a game lobby - Leave(Result<(), RoomErr>), + Leave(Result<(), LobbyErr>), /// Get the new set of ready states - Ready(RoomUpdate), + Ready(LobbyUpdate), /// Receiving a start request time StartReq(DateTime<Utc>), /// Response to the action with the state update GameUpdate(UpdateState), /// Leave the match (forfeit) LeaveGame(Result<(), MatchErr>), - } #[derive(Serialize, Deserialize)] @@ -53,17 +52,23 @@ pub enum AuthErr { } #[derive(Serialize, Deserialize)] -pub enum RoomErr { +pub enum LobbyErr { /// The requested room is already full RoomFull, /// The room id is unknown NoSuchRoom, /// Previously not in room NotInRoom, + /// Not everybody was ready + NotAllReady, + /// A request was sent by someone who isn't authorised + NotAuthorized, + /// Other internal error, try again? + OtherError, } #[derive(Serialize, Deserialize)] -pub enum RoomUpdate { +pub enum LobbyUpdate { /// The set of ready users Ready(Vec<UserId>), } |