java.lang.Object
javafx.application.Application
polimi.ingsw.am21.codex.view.GUI.Gui
All Implemented Interfaces:
Remote, GameEventListener, RemoteGameEventListener, View

public class Gui extends javafx.application.Application implements View
  • Constructor Details

    • Gui

      public Gui()
  • Method Details

    • getInstance

      public static Gui getInstance()
    • setClient

      public void setClient(ClientConnectionHandler client)
      Specified by:
      setClient in interface View
    • start

      public void start(javafx.stage.Stage primaryStage)
      Specified by:
      start in class javafx.application.Application
    • getIsInitializedLatch

      public CountDownLatch getIsInitializedLatch()
    • main

      public static void main(String[] args)
    • postNotification

      public void postNotification(NotificationType notificationType, String message)
      Posts a push notification to the user
      Specified by:
      postNotification in interface View
      Parameters:
      notificationType - the type of notification to display (CONFIRM, WARNING, ERROR, UPDATE, RESPONSE)
      message - the message to display
    • postNotification

      public void postNotification(Notification notification)
      Posts a push notification to the user
      Specified by:
      postNotification in interface View
      Parameters:
      notification - the notification to display
    • postNotification

      public void postNotification(NotificationType notificationType, String[] messages, Colorable colorable, int colorableIndex)
      Specified by:
      postNotification in interface View
    • displayException

      public void displayException(Exception exception)
      Displays an exception to the user
      Specified by:
      displayException in interface View
      Parameters:
      exception - the exception to display
    • drawAvailableGames

      public void drawAvailableGames()
      Draw the available games in the lobby menu
      Specified by:
      drawAvailableGames in interface View
    • drawAvailableTokenColors

      public void drawAvailableTokenColors()
      Draw a list of available token colors for the player to choose from
      Specified by:
      drawAvailableTokenColors in interface View
    • drawLobby

      public void drawLobby()
      Draw the current status of the lobby and its connected players alongside the lobby window
      Specified by:
      drawLobby in interface View
    • drawLeaderBoard

      public void drawLeaderBoard()
      Draw the leaderboard of the game, display the players and their points
      Specified by:
      drawLeaderBoard in interface View
    • drawResourcesAndObjects

      public void drawResourcesAndObjects(LocalPlayer player)
      Draw a map of the given player available resources and objects to the playerBoard
      Parameters:
      player - the player whose resources are to be drawn
    • drawNicknameChoice

      public void drawNicknameChoice()
      Draw the scene for the player to choose a nickname
      Specified by:
      drawNicknameChoice in interface View
    • getLocalModel

      public LocalModelContainer getLocalModel()
      Specified by:
      getLocalModel in interface View
    • drawPlayerBoards

      public void drawPlayerBoards()
      Specified by:
      drawPlayerBoards in interface View
    • drawPlayerBoard

      public void drawPlayerBoard(String nickname, int verticalOffset, int horizontalOffset)
      Specified by:
      drawPlayerBoard in interface View
    • drawPlayerBoard

      public void drawPlayerBoard(String nickname)
      Draw the placed cards of the given player
      Specified by:
      drawPlayerBoard in interface View
      Parameters:
      nickname - The nickname of the player whose playerboard is to be drawn
    • drawGame

      public void drawGame()
      Draw the playerboard and gameboard scenes after every player has finished in the lobby
      Specified by:
      drawGame in interface View
    • drawGameBoard

      public void drawGameBoard()
      Draw the gameboard contents.
      Specified by:
      drawGameBoard in interface View
    • drawGameOver

      public void drawGameOver()
      Display the game is over and the final leaderboard
      Specified by:
      drawGameOver in interface View
    • drawCard

      public void drawCard(Card card)
      Specified by:
      drawCard in interface View
    • drawHand

      public void drawHand()
      Draws the hand of the player
      Specified by:
      drawHand in interface View
    • drawPairs

      public void drawPairs()
      Draws the pairs of resource and gold cards which the player can draw from
      Specified by:
      drawPairs in interface View
    • drawObjectiveCardChoice

      public void drawObjectiveCardChoice()
      Draw the two objective cards the player can choose from in the lobby
      Specified by:
      drawObjectiveCardChoice in interface View
    • drawStarterCardSides

      public void drawStarterCardSides()
      Draw the sides of the starter card the player can choose from in the lobby
      Specified by:
      drawStarterCardSides in interface View
    • drawChat

      public void drawChat()
      Load the chat scene for chat messages to be drawn in.
    • drawChatMessage

      public void drawChatMessage(ChatMessage message)
      Draw a chat message in the chat window
      Specified by:
      drawChatMessage in interface View
    • drawCommonObjectiveCards

      public void drawCommonObjectiveCards()
      Draw the common objective cards in the gameboard
      Specified by:
      drawCommonObjectiveCards in interface View
    • drawPlayerObjective

      public void drawPlayerObjective()
      Draw the player objective card in its player board alongside its hand
      Specified by:
      drawPlayerObjective in interface View
    • drawCardDecks

      public void drawCardDecks()
      Draw the card decks in the gameboard
      Specified by:
      drawCardDecks in interface View
    • listGames

      public void listGames()
      Specified by:
      listGames in interface View
    • gameCreated

      public void gameCreated(String gameId, int currentPlayers, int maxPlayers)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the game creation event.
      Specified by:
      gameCreated in interface GameEventListener
      Specified by:
      gameCreated in interface RemoteGameEventListener
      Specified by:
      gameCreated in interface View
      Parameters:
      gameId - The unique identifier of the game that has just been created.
      currentPlayers - The number of players currently in the game.
      maxPlayers - The maximum number of players that can join the game.
    • gameDeleted

      public void gameDeleted(String gameId)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the game deletion event.
      Specified by:
      gameDeleted in interface GameEventListener
      Specified by:
      gameDeleted in interface RemoteGameEventListener
      Specified by:
      gameDeleted in interface View
      Parameters:
      gameId - The identifier of the game that has just been deleted.
    • playerJoinedLobby

      public void playerJoinedLobby(String gameId, UUID connectionID)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player joining a game lobby.
      Specified by:
      playerJoinedLobby in interface GameEventListener
      Specified by:
      playerJoinedLobby in interface RemoteGameEventListener
      Specified by:
      playerJoinedLobby in interface View
      Parameters:
      gameId - The identifier of the game lobby that the player has joined.
      connectionID - The unique identifier of the player that has joined the lobby.
    • playerLeftLobby

      public void playerLeftLobby(String gameId, UUID connectionID)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player leaving a game lobby.
      Specified by:
      playerLeftLobby in interface GameEventListener
      Specified by:
      playerLeftLobby in interface RemoteGameEventListener
      Specified by:
      playerLeftLobby in interface View
      Parameters:
      gameId - The identifier of the game lobby that the player has left.
      connectionID - The unique identifier of the player that has left the lobby.
    • playerSetToken

      public void playerSetToken(String gameId, UUID connectionID, String nickname, TokenColor token)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player choosing their token color.
      Specified by:
      playerSetToken in interface GameEventListener
      Specified by:
      playerSetToken in interface RemoteGameEventListener
      Specified by:
      playerSetToken in interface View
      Parameters:
      gameId - The identifier of the game lobby in which the player has set their token color.
      connectionID - The unique identifier of the player that has set their token color.
      nickname - The nickname of the player that has set their token color, if they have chosen it already
      token - The token color that the player has chosen
    • playerSetNickname

      public void playerSetNickname(String gameId, UUID connectionID, String nickname)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player choosing their nickname.
      Specified by:
      playerSetNickname in interface GameEventListener
      Specified by:
      playerSetNickname in interface RemoteGameEventListener
      Specified by:
      playerSetNickname in interface View
      Parameters:
      gameId - The identifier of the game lobby in which the player has set their nickname.
      connectionID - The unique identifier of the player that has set their nickname.
      nickname - The nickname of the player that has set their nickname
    • playerChoseObjectiveCard

      public void playerChoseObjectiveCard(String gameId, UUID connectionID, String nickname)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player choosing their objective card.
      Specified by:
      playerChoseObjectiveCard in interface GameEventListener
      Specified by:
      playerChoseObjectiveCard in interface RemoteGameEventListener
      Specified by:
      playerChoseObjectiveCard in interface View
      Parameters:
      gameId - The identifier of the game lobby in which the player has set their objective card.
      connectionID - The unique identifier of the player that has set their objective card.
      nickname - The nickname of the player that has set their objective card, if they have chosen it already
    • gameStarted

      public void gameStarted(String gameId, GameInfo gameInfo)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a game starting.
      Specified by:
      gameStarted in interface GameEventListener
      Specified by:
      gameStarted in interface RemoteGameEventListener
      Specified by:
      gameStarted in interface View
      Parameters:
      gameId - The identifier of the game that has just started.
      gameInfo - The information about the game that has just started.
    • gameOver

      public void gameOver()
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of the game ending.
      Specified by:
      gameOver in interface GameEventListener
      Specified by:
      gameOver in interface RemoteGameEventListener
      Specified by:
      gameOver in interface View
    • playerScoresUpdate

      public void playerScoresUpdate(Map<String,Integer> newScores)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of the player's score being updated after the game ends and secret and common objectives are evaluated.
      Specified by:
      playerScoresUpdate in interface GameEventListener
      Specified by:
      playerScoresUpdate in interface RemoteGameEventListener
      Specified by:
      playerScoresUpdate in interface View
      Parameters:
      newScores - A map containing the updated scores of the players. The key is the nickname of the player and the value is the new score of the player.
    • remainingRounds

      public void remainingRounds(String gameID, int remainingRounds)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of the number of remaining rounds being updated or set when winning score is reached by any of the players.
      Specified by:
      remainingRounds in interface GameEventListener
      Specified by:
      remainingRounds in interface RemoteGameEventListener
      Specified by:
      remainingRounds in interface View
      Parameters:
      gameID - The identifier of the game in which the number of remaining rounds was updated.
      remainingRounds - The number of rounds remaining in the game.
    • winningPlayer

      public void winningPlayer(String nickname)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process and display the winning player of the game.
      Specified by:
      winningPlayer in interface GameEventListener
      Specified by:
      winningPlayer in interface RemoteGameEventListener
      Specified by:
      winningPlayer in interface View
      Parameters:
      nickname - The nickname of the player that has won the game.
    • playerConnectionChanged

      public void playerConnectionChanged(UUID connectionID, String nickname, GameController.UserGameContext.ConnectionStatus status)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player's connection status changing.
      Specified by:
      playerConnectionChanged in interface GameEventListener
      Specified by:
      playerConnectionChanged in interface RemoteGameEventListener
      Specified by:
      playerConnectionChanged in interface View
      Parameters:
      connectionID - The unique identifier of the player whose connection status has changed. This is the identifier that the player uses to connect to the server.
      nickname - The nickname of the player whose connection status has changed.
      status - The new connection status of the player.
    • lobbyInfo

      public void lobbyInfo(LobbyUsersInfo usersInfo)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player joining a game lobby when there are other players already inside it that may or may not have already completed the process of joining the game.
      Specified by:
      lobbyInfo in interface GameEventListener
      Specified by:
      lobbyInfo in interface RemoteGameEventListener
      Specified by:
      lobbyInfo in interface View
      Parameters:
      usersInfo - The information about the users in the lobby. It includes the nickname, token color, objective card choice, starter card side chosen, and in-game status of each user.
    • chatMessage

      public void chatMessage(String gameID, ChatMessage message)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of a player sending a chat message in the game they're in.
      Specified by:
      chatMessage in interface GameEventListener
      Specified by:
      chatMessage in interface RemoteGameEventListener
      Specified by:
      chatMessage in interface View
      Parameters:
      gameID - The identifier of the game in which the chat message was sent.
      message - The chat message that was sent by the player.
    • gameHalted

      public void gameHalted(String gameID)
      Specified by:
      gameHalted in interface GameEventListener
      Specified by:
      gameHalted in interface RemoteGameEventListener
    • gameResumed

      public void gameResumed(String gameID)
      Specified by:
      gameResumed in interface GameEventListener
      Specified by:
      gameResumed in interface RemoteGameEventListener
    • userContext

      public void userContext(FullUserGameContext context)
      Specified by:
      userContext in interface GameEventListener
      Specified by:
      userContext in interface RemoteGameEventListener
    • cardPlaced

      public void cardPlaced(String gameId, String playerId, Integer playerHandCardNumber, Integer cardId, CardSideType side, Position position, int newPlayerScore, Map<ResourceType,Integer> updatedResources, Map<ObjectType,Integer> updatedObjects, Set<Position> availableSpots, Set<Position> forbiddenSpots)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of the current player placing a card on their playerboard.
      Specified by:
      cardPlaced in interface GameEventListener
      Specified by:
      cardPlaced in interface RemoteGameEventListener
      Specified by:
      cardPlaced in interface View
      Parameters:
      gameId - The identifier of the game in which the card was placed.
      playerId - The identifier of the player that placed the card.
      playerHandCardNumber - The number of the card in the player's hand that was placed.
      cardId - The unique identifier of the card that was placed.
      side - The side of the card that was placed.
      position - The position on the player board where the card was placed.
      newPlayerScore - The updated score of the player that placed the card.
      updatedResources - The updated resources of the player that placed the card. The key is the type of resource and the value is the new amount of that resource.
      updatedObjects - The updated objects of the player that placed the card. The key is the type of object and the value is the new amount of that object.
      availableSpots - A set of positions that are available for the next player to place a card.
      forbiddenSpots - A set of positions that are forbidden for the next player to place a card. This set is used to display the forbidden spots on the gameboard.
    • changeTurn

      public void changeTurn(String gameId, String playerNickname, Integer playerIndex, Boolean isLastRound, Set<Position> availableSpots, Set<Position> forbiddenSpots, Integer resourceDeckTopCardId, Integer goldDeckTopCardId)
      Description copied from interface: RemoteGameEventListener
      Interface method used to process the event of the player ending their turn choosing not to draw a card. This possibility is given by the fact that the decks might be empty, A player can choose not to draw in their last turn if they prefer not to draw from the pairs available on the gameboard
      Specified by:
      changeTurn in interface GameEventListener
      Specified by:
      changeTurn in interface RemoteGameEventListener
      Specified by:
      changeTurn in interface View
      Parameters:
      gameId - The unique identifier of the game that has just ended.
      playerNickname - The player that has just finished their turn
      playerIndex - The index of the player that has just finished their turn in the list of players.
      isLastRound - A boolean indicating if this is the last round of the game.
      availableSpots - A set of positions that are available for the next player to place a card.
      forbiddenSpots - A set of positions that are forbidden for the next player to place a card.
      resourceDeckTopCardId - The unique identifier of the top card in the resource deck.
      goldDeckTopCardId - The unique identifier of the top card in the gold deck.