Send the complete board when joining a room
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::types::{Position2dRef, TileRef};
|
||||
use board_shared::{position::Position2d, tile::Tile};
|
||||
use crate::types::{BoardRef, Position2dRef, TileRef};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A message sent by the client to the server.
|
||||
@@ -20,9 +19,9 @@ pub enum ClientMessage {
|
||||
/// Try to place a tile from the hand on the board.
|
||||
///
|
||||
/// The server will validate the move and answer with a TilePlaced if the message is valid.
|
||||
TileUse(#[serde(with = "Position2dRef")] Position2d, usize),
|
||||
TileUse(Position2dRef, usize),
|
||||
/// Try to remove a tile from the board to add it to the hand.
|
||||
TileTake(#[serde(with = "Position2dRef")] Position2d),
|
||||
TileTake(Position2dRef),
|
||||
/// Get the server to validate the current player moves.
|
||||
Validate,
|
||||
}
|
||||
@@ -34,6 +33,7 @@ pub enum ServerMessage {
|
||||
JoinedRoom {
|
||||
room_name: String,
|
||||
players: Vec<(String, u32, bool)>,
|
||||
board: BoardRef,
|
||||
active_player: usize,
|
||||
has_started: bool,
|
||||
},
|
||||
@@ -48,13 +48,10 @@ pub enum ServerMessage {
|
||||
/// Change the current player
|
||||
PlayerTurn(usize),
|
||||
/// Update the current hand of the player
|
||||
SyncHand(#[serde(with = "TileRef")] Tile), // TODO: Vec<Tile>
|
||||
SyncHand(Vec<TileRef>),
|
||||
/// Informs that a tile has been placed
|
||||
TilePlaced(
|
||||
#[serde(with = "Position2dRef")] Position2d,
|
||||
#[serde(with = "TileRef")] Tile,
|
||||
),
|
||||
TilePlaced(Position2dRef, TileRef),
|
||||
/// Informs that a tile has been removed
|
||||
TileRemoved(#[serde(with = "Position2dRef")] Position2d),
|
||||
TileRemoved(Position2dRef),
|
||||
TurnRejected(String),
|
||||
}
|
||||
|
Reference in New Issue
Block a user