public class GameController extends SugarMessageProcessor
  • Field Details

    • roomId

      public final UUID roomId
    • players

      private final List<Player> players
    • isExpertMode

      private final boolean isExpertMode
    • communicationController

      private CommunicationController communicationController
    • gameStarted

      private boolean gameStarted
  • Constructor Details

  • Method Details

    • addPlayerEffective

      private void addPlayerEffective(Player player)
    • activePlayers

      public int activePlayers()
    • removePlayer

      public void removePlayer(String username)
    • getPlayers

      public List<Player> getPlayers()
    • addPlayer

      public void addPlayer(Player player)
    • startGame

      Throws:
      GameStateInitializationFailureException
      EmptyStudentSupplyException
    • containsPeer

      public boolean containsPeer(Peer peer)
      Return true if there is the player in the game
      Parameters:
      peer - of the player to check
      Returns:
      true if the players list contains the peer provided
    • containsPlayer

      public boolean containsPlayer(String username)
      Return true if there is the player in the game
      Parameters:
      username - of the player to check
      Returns:
      true if the players list contains the player provided
    • getPeerFromPlayer

      public Optional<Peer> getPeerFromPlayer(@NotNull @NotNull String username) throws IllegalArgumentException
      Returns a peer associated to the username provided
      Parameters:
      username - of the player
      Returns:
      an Optional that contains the peer, or it can be empty
      Throws:
      IllegalArgumentException
    • updatePeerIfOlder

      public void updatePeerIfOlder(@NotNull @NotNull String username, @NotNull @NotNull Peer peer)
      Used when a player plays a move, it checks if the user has logged In from a new connection, if yes, it updates the peer socket
      Parameters:
      username - of the player
      peer - to check if it has changed
    • getTeamPeers

      public List<Peer> getTeamPeers(String username)
      Returns the peers of the player's team
      Parameters:
      username - of the player
      Returns:
      a List that contains the player's team peers
    • getLightGameState

      public LightGameState getLightGameState()
    • getGameUUID

      public UUID getGameUUID()
    • setInactivePlayer

      public void setInactivePlayer(Peer peer)
    • base

      public SugarMessage base(SugarMessage message, Peer peer)