Skip to content

[server] Implement server-side board simulation (matches) #7

@lunacys

Description

@lunacys

After a lobby starts, a new match is started.
Each match consists of a number of boards which equals to the total number of players in the match.

Players executes an input (move, rotate, drop, etc), client-side board interprets it, then client sends the command to the server, which also interprets it.

Each move is sent to all players in the match to replicate the board's state so a player sees other's boards.

Server-side simulation is needed to guarantee game consistency, e.g. a player cheats and modifies his game client, which makes pieces move and rotate freely ignoring current board state.

If a move results in an error:

pub fn hard_drop(&mut self) -> Result<MoveResult, BoardErrorReason> {

or the board is dead:
pub is_dead: bool,

then the player has lost the match.

Also, all attacks are going through the server and it calculates outgoing garbage and selects a player to send the garbage to.

Subtasks:

  • Receive player inputs (commands) via WebSockets
  • Interpret the inputs
  • Broadcast send the inputs to other players
  • Add board validation method which compares client-side and server-side board states
  • Add a method for getting player's board state
  • Calculate damage and send garbage

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new featureserverGame Server related tasks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions