Class GameSetupHandler

java.lang.Object
it.polimi.ingsw.eriantys.controller.phases.GameSetupHandler
All Implemented Interfaces:
MessageHandler

public class GameSetupHandler extends Object implements MessageHandler
This concrete implementation for the state design pattern involving MessageHandler defines how the game setup phase message GameSetupSelection should be processed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new GameSetupHandler for the specified game.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a help message which lists the possible user actions for the current phase of the game.
    void
    Handles and responds to the specified message received by the client, according to the rules regarding the current phase of the game.
    void
    Plays the specified user's turn according to the rules if they are disconnected and the game is not idle.
    void
    Sends a broadcast update after the specified user's reconnection in order to make sure every player has the information they need in order to play.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GameSetupHandler

      public GameSetupHandler(Game game)
      Constructs a new GameSetupHandler for the specified game.
      Parameters:
      game - the Game this message handler refers to.
  • Method Details

    • handle

      public void handle(GameMessage m) throws NoConnectionException
      Description copied from interface: MessageHandler
      Handles and responds to the specified message received by the client, according to the rules regarding the current phase of the game.
      Specified by:
      handle in interface MessageHandler
      Parameters:
      m - the GameMessage received by the client.
      Throws:
      NoConnectionException - if no connection can be retrieved for the sender of the message.
    • getHelp

      public String getHelp()
      Description copied from interface: MessageHandler
      Returns a help message which lists the possible user actions for the current phase of the game.
      Specified by:
      getHelp in interface MessageHandler
      Returns:
      a help message which lists the possible user actions for the current phase of the game.
    • handleDisconnectedUser

      public void handleDisconnectedUser(String username)
      Description copied from interface: MessageHandler
      Plays the specified user's turn according to the rules if they are disconnected and the game is not idle.
      Specified by:
      handleDisconnectedUser in interface MessageHandler
      Parameters:
      username - the disconnected user's username.
    • sendReconnectUpdate

      public void sendReconnectUpdate(String username)
      Description copied from interface: MessageHandler
      Sends a broadcast update after the specified user's reconnection in order to make sure every player has the information they need in order to play.
      Specified by:
      sendReconnectUpdate in interface MessageHandler
      Parameters:
      username - the reconnected user's username.