Include a serde feature in the shared crate

This commit is contained in:
2024-03-23 13:36:28 +01:00
parent 3d93bf0fda
commit f1962503b8
22 changed files with 134 additions and 281 deletions

View File

@@ -1,4 +1,6 @@
use crate::types::{BoardRef, Position2dRef, TileRef};
use board_shared::board::Board;
use board_shared::position::Position2d;
use board_shared::tile::Tile;
use serde::{Deserialize, Serialize};
/// A message sent by the client to the server.
@@ -19,11 +21,11 @@ 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(Position2dRef, usize),
TileUse(Position2d, usize),
/// Try to place an equal sign on the board.
TilePlaceEqual(Position2dRef),
TilePlaceEqual(Position2d),
/// Try to remove a tile from the board to add it to the hand.
TileTake(Position2dRef),
TileTake(Position2d),
/// Get the server to validate the current player moves.
Validate,
}
@@ -35,7 +37,7 @@ pub enum ServerMessage {
JoinedRoom {
room_name: String,
players: Vec<(String, u32, bool)>,
board: BoardRef,
board: Board,
active_player: usize,
has_started: bool,
},
@@ -50,13 +52,13 @@ pub enum ServerMessage {
/// Change the current player
PlayerTurn(usize),
/// Update the current hand of the player
SyncHand(Vec<TileRef>),
SyncHand(Vec<Tile>),
/// Update the score of the n-th player.
SyncScore(usize, u32),
/// Informs that a tile has been placed
TilePlaced(Position2dRef, TileRef),
TilePlaced(Position2d, Tile),
/// Informs that a tile has been removed
TileRemoved(Position2dRef),
TileRemoved(Position2d),
TurnRejected(String),
/// Notify that the game has ended.
GameOver,