Class CommunicationController

java.lang.Object
it.polimi.ingsw.communication.sugar_framework.message_processing.SugarMessageProcessor
it.polimi.ingsw.server.controller.game_state_controller.CommunicationController
Direct Known Subclasses:
ExpertCommunicationController

public class CommunicationController extends SugarMessageProcessor
  • Field Details

  • Constructor Details

  • Method Details

    • initializeGameStateController

      protected GameStateController initializeGameStateController(int playersNumber) throws GameStateInitializationFailureException
      Throws:
      GameStateInitializationFailureException
    • initializeGameStateController

      protected GameStateController initializeGameStateController(UUID gameUUID)
    • createCommunicationController

      public static CommunicationController createCommunicationController(List<Player> players, boolean isExpertMode) throws GameStateInitializationFailureException
      Throws:
      GameStateInitializationFailureException
    • createCommunicationController

      public static CommunicationController createCommunicationController(List<org.javatuples.Pair<String,Integer>> players, boolean isExpertMode, UUID gameUUID)
    • isOthersPlayersTurn

      boolean isOthersPlayersTurn(String player)
      This method whether a move was sent by the current player or not.
      Parameters:
      player - indicates a peer, therefore a player,
      Returns:
      true if the move has to be processed, because it is performed by the current player, false otherwise.
    • rollbackMsg

      public SugarMessage rollbackMsg(RollbackMsg message, Peer peer)
      This method is the handler for the RollBackMsg
      Parameters:
      message - is the RollBackMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • playCardMsg

      public SugarMessage playCardMsg(PlayCardMsg message, Peer peer)
      This method is the handler for the PlayCardMsg
      Parameters:
      message - is the PlayCardMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • moveStudentFromEntranceToDiningRoomMsg

      public SugarMessage moveStudentFromEntranceToDiningRoomMsg(MoveStudentFromEntranceToDiningRoomMsg message, Peer peer)
      This method is the handler fot the MoveStudentFromEntranceToDiningRoomMsg
      Parameters:
      message - is the MoveStudentFromEntranceToDiningRoomMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • moveStudentFromEntranceToArchipelagoMsg

      public SugarMessage moveStudentFromEntranceToArchipelagoMsg(MoveStudentFromEntranceToArchipelagoMsg message, Peer peer)
      This method is the handler for the MoveStudentFromEntranceToArchipelagoMsg
      Parameters:
      message - is the MoveStudentFromEntranceToArchipelagoMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • moveMotherNatureMsg

      public SugarMessage moveMotherNatureMsg(MoveMotherNatureMsg message, Peer peer)
      This method is the handler for the MoveMotherNatureMsg
      Parameters:
      message - is the MoveMotherNatureMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • grabStudentsFromCloudMsg

      public SugarMessage grabStudentsFromCloudMsg(GrabStudentsFromCloudMsg message, Peer peer)
      This method is the handler for the GrabStudentsFromCloudMsg
      Parameters:
      message - is the GrabStudentsFromCloudMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • endTurnMsg

      public SugarMessage endTurnMsg(EndTurnMsg message, Peer peer)
      This method is the handler for the EndTurnMsg
      Parameters:
      message - is the EndTurnMsg
      peer - is the Peer from which the message is received
      Returns:
      a SugarMessage with the response of the invocation
    • getTeamUsernames

      public List<String> getTeamUsernames(String username)
      Returns the usernames in my team
      Parameters:
      username - of the player
      Returns:
      a List that contains all the users in my team, in 2/3 players games, it returns a list containing only the given username
    • getLightGameState

      public LightGameState getLightGameState()
      Return light game state from the communication controller
      Returns:
      light game state
    • getUsernameToWinnerMap

      protected Map<String,Boolean> getUsernameToWinnerMap(Map<Integer,Boolean> schoolBoardIdToWinnerMap)
    • getGameUUID

      public UUID getGameUUID()
    • getSchoolBoardIdFromUsername

      private int getSchoolBoardIdFromUsername(String player)
    • getUsernameFromSchoolBoardId

      private String getUsernameFromSchoolBoardId(int schoolBoardId)
    • base

      public void base(SugarMessage message, Peer peer) throws UnhandledMessageAtLowestLayerException
      Throws:
      UnhandledMessageAtLowestLayerException