Class ViewGUIControllerMatch

java.lang.Object
it.polimi.ingsw.am13.client.view.gui.ViewGUIController
it.polimi.ingsw.am13.client.view.gui.ViewGUIControllerMatch

public class ViewGUIControllerMatch extends ViewGUIController
Controller of 'Match' scene, where player can actually play the most of the game
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.control.Label
    Label displaying the current game action to perform
    private javafx.scene.control.Label
    Label for counter of animal resources in the field of displayPlayer
    private javafx.scene.shape.Rectangle
    The card box in which thisPlayer has placed a card, before he receives confirmation from the server of the fact that the card was played successfully
    private javafx.scene.image.ImageView
    The ImageView of the card on the field that thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    private javafx.scene.image.ImageView
    The ImageView of the hand card thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    private javafx.scene.control.Button
    The button used to flip the hand card thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    private Chat
     
    private javafx.scene.control.TextArea
     
    private javafx.scene.control.ChoiceBox<List<PlayerLobby>>
     
    private javafx.scene.control.TextField
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    Controller for the initialization view
    Controller for the winner view
    private static final int
    Width of a visible corner of the image of a card
    private static final int
    Height of a visible corner of the image of a card
    private Map<Resource,javafx.scene.control.Label>
    A map associating each resource to its Label
    private PlayerLobby
    Player whose field and back of hand cards are currently being displayed
    private javafx.scene.control.Label
    Label displaying the name of the player whose field is currently being displayed
    private javafx.scene.layout.StackPane
    Container where to stack the cards to display for the player's field ImageView and Rectangle for card placed and available coords are added to this container for the field
    private javafx.scene.control.ScrollPane
    ScrollPane containing the field.
    private boolean
    Flag indicating if the first scroll adjustment to center the starter card has already happened Hence it is set to true each time the displayPlayer changes
    private javafx.scene.control.Button
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.Button
     
    private List<javafx.scene.control.Button>
    The buttons to flip the hand cards of thisPlayer
    private boolean
    True if it is the turn of thisPlayer and he has played a card, false otherwise
    private javafx.scene.control.Label
    Label for counter of fungus resources in the field of displayPlayer
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.control.TextArea
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private List<javafx.scene.image.ImageView>
    The images of the cards in the hand of displayPlayer
    private List<Side>
    The sides on which each of the hand cards are being displayed
    private javafx.scene.image.ImageView
     
    The playable cards in the hand of displayPlayer
    private static final int
    Entire height of the image of a card
    private static final int
    Entire width of the image of a card
    private javafx.scene.shape.Rectangle
    Overlay rectangle for the init view
    private javafx.scene.control.Label
    Label for counter of inkwell resources in the field of displayPlayer
    private javafx.scene.control.Label
    Label for counter of insect resources in the field of displayPlayer
    private LogGUI
    Handler of the logs
    private javafx.scene.control.TextArea
    Area of non-editable text for showing logs
    private javafx.scene.control.Label
    Label for counter of manuscript resources in the field of displayPlayer
    private boolean
    Flag indicating if the current background music track has begun or not
    private javafx.scene.control.Button
     
    private javafx.scene.media.MediaPlayer
    Player of the background music
    private javafx.scene.control.ChoiceBox<String>
     
    static final Map<String,String>
    Map associating the strings shown in the choice box for the music tracks with the respective file name of the audio file.
    private javafx.scene.control.Slider
     
    private javafx.scene.image.ImageView
     
    private javafx.beans.value.ChangeListener<Number>
    Listener for the main window's height used for the overlay in init and winner view
    private javafx.beans.value.ChangeListener<Number>
    Listener for the main window's width used for the overlay in init and winner view
    private javafx.scene.layout.Pane
     
    private javafx.scene.control.Label
    Label for counter of plant resources in the field of displayPlayer
    private Map<PlayerLobby,javafx.scene.Node>
    A map associating to the nickname of each player the VBox in which his information is being displayed
    private javafx.scene.layout.GridPane
    Container for the labels displaying the players in game (to the left of the screen)
    A map storing the playable cards in the hand of each player
    private javafx.scene.control.Label
    Label for counter of quill resources in the field of displayPlayer
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.image.ImageView
     
    private final Map<PlayerLobby,Integer>
    Map associating each player to the current saved points, before a new eventual modification
    private javafx.scene.layout.StackPane
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.control.Button
     
    private boolean
    Flag indicating if sounds must be played
    private javafx.scene.control.Slider
     
    private GameState
    Game's state.
    private static final long
    Only for debug: delay for doing actions in SKIP_TURNS mode
    private PlayerLobby
    Player associated to the client the GUI was created by
    private static final double
    Horizontal offset of overlapped tokens
    private static final int
    Width/Height of the tokens visible on top of the starter card on the field
    private static final double
    Token dimension (square shape) relative to width (x) of the score tracker
    private final Map<PlayerLobby,javafx.scene.image.ImageView>
    Map associating each player to its token image in the score tracker
    private final Map<PlayerLobby,Double>
    Map associating each player to the current graphical x-offset for their token on the scroeboard, with respect to the main coordinates of their points.
    private javafx.scene.image.ImageView
    Background image ofr counter of turns to the end of the game
    private javafx.scene.control.Label
    Label for counter visible during final phase, displaying the number of turns left to the end of the game
    private static final List<Double>
    Relative coordinates for x-positions of tokens on the score tracker
    private static final List<Double>
    Relative coordinates for y-positions of tokens on the score tracker

    Fields inherited from class it.polimi.ingsw.am13.client.view.gui.ViewGUIController

    networkHandler, scene, stage
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    addCardBox(Coordinates coordinates, List<CardPlayableIF> finalHandPlayable)
    This method adds a box at the passed coordinates.
    private void
    Adjust field container size to contain all the cards displayed in it.
    private void
    It changes the current track chosen for the player of background music.
    private void
    Clear the pickable cards
    private javafx.scene.image.ImageView
    Creates the image for the color token of the given player, and places it on the position 0 of the score tracker
    private List<javafx.animation.PathTransition>
    createAnimationTokenMove(PlayerLobby player, int from, int to, List<PlayerLobby> animationPlayers)
    Creates and plays an animation of the given token moving on the scoretrakcer.
    private javafx.animation.PathTransition
    Creates and plays an animation moving the token of the specified player of an 'offset less', if its token has an offset > 0.
    private javafx.scene.image.ImageView
    Creates the image for the color token of the given player
    private void
    displayCard(String id, Side side, javafx.scene.image.ImageView imageView)
    It opens the image corresponding to the passed id and side, adds it to the passed ImageView and then sets the height and width (they will always be the same since the only images that need to be displayed are cards).
    private void
    This method displays the field of displayPlayer, by displaying all the placed cards and adding boxes at each available coordinate.
    void
    Display the personal objective card
    private void
    this method displays the hand of playable cards of displayPlayer If displayPlayer is thisPlayer, it prints the card on the front, adds the buttons to flip them and make them draggable if it is the turn of thisPlayer.
    private void
    Display the pickable cards and the common objectives
    private void
    flipCard(int i, javafx.scene.image.ImageView handCard)
    It flips the hand card by switching the corresponding value of handCardSides and then displaying the new side.
    void
    Force closing the app.
     
    void
    init(ViewGUIControllerInit controllerInit, ViewGUIControllerWinner controllerWinner, Chat chat)
    Initialization method, it must be called as first method before starting using the object.
    private void
    It initializes the sounds and music section in settings
    private void
    Initialize the player container
    private void
    Initializes the score tracker view and creates all the tokens as image views.
    private void
    makeDraggable(int handPlayableIndex, javafx.scene.image.ImageView imageView, javafx.scene.control.Button flipButton)
    It makes the card corresponding to the parameters draggable.
    void
    onChatTextFieldKeyPressed(javafx.scene.input.KeyEvent event)
    When enter is pressed on the keyboard, the message is sent
    void
    Method associated to the button for resetting the scroll/zoom of the field
    void
    When the button is clicked, if there is a message and a receiver has been selected, a chat message is sent.
    void
     
    void
    Method associated to the button for zooming out the field
    void
    Method associated to the button for zooming in the field
    void
    onMouseWheelScroll(javafx.scene.input.ScrollEvent scrollEvent)
    Method associated to the scroll (CTRL + scroll of mouse wheel) to zoom/dezoom the field
    void
    Handler of the click of the music button in settings.
    private void
     
    private void
    Action performed to return to homepage, actually disconnecting voluntarily from the game.
    void
    Handler of the click of the sound button in settings.
    private void
    playAudio(String fileName)
    Plays the specified audio file if audio is currently on, with volume indicated by soundsVolSlider The file must be in relative path /sounds with respect to the fxml file
    private void
    Updates player container connection status of the player which has disconnected or reconnected.
    private void
    Updates player container labels representing the turn of the players.
    private void
    playTransitionAppearLeftRight(javafx.scene.Node node, double totWidth)
    Creates and plays a transition making the given node appearing with the slide of a clip from left to right
    private void
    selectMusicImage(boolean playing)
    Sets the right image for background music button in settings
    private void
    Sets the right image for sounds button in settings
    void
    setChat(Chat chat)
    Sets the chat, and initializes chatChoices with the valid choices.
    void
    Method that sets the gameState
    void
    Method that sets the player
    void
    If the message belongs to the chat that is currently being selected, it shows it.
    private void
    Clears the chat area and replaces it with all the messages between thisPlayer and the passed parameter
    void
    Show that a player showed his personal objectiveby calling the corresponding method on ViewGUIControllerInit, adding the corresponding log and displaying the logs
    void
     
    void
    Shows a generic exception in the view (specific exception could be handled in different ways, also depending on the phase or the state of game)
    void
    Sho the logs, update the turnsCounterLabel
    void
    Show that we reached the in game phase, by removed the init scene and the transparent overlay, adding the log message, updating the hand playable, field and players container
    private void
    Updates the logArea to show the last non-shown log messages
    void
    Make all the updates necessary to make it the turn of the next player
    void
    Show that a card was picked by making the pickable cards not clickable, updating playersHandsPlayable and displaying the hand playable
    void
    If the player is thisPlayer, set to true flowCardPlaced, make the pickable cards clickable and update actionLabel.
    void
    Show that player his starting card by calling the corresponding method on ViewGUIControllerInit, displaying in the field , adding the corresponding log and displaying the logs
    void
    It shows that a player disconnected from an ongoing game by updating the player container
    void
    It shows that a player reconnected to an ongoing game by updating the player container
    void
    Show the start of the game by creating a semi transparent layer and displaying the init scene on top of it
    void
    Modifies all the elements on the view in order to update them with the final value and not to allow any other modifications.
    void
    Creates a new layer over all the view, which closes after the first click of the mouse
    private void
    Starts playing the current track selected in the music track choice box.
    private void
    switchToPlayer(PlayerLobby displayPlayer)
    This method updates displayPlayer and displays his field and playable hand
    private void
    Update the actionLabel's text, according to the current phase of the game flow for thisPlayer
    private void
    Updates the position of the token image on the score tracker, according to the actual points of the player.
    private void
    Recursive creation and concatenation of the animation for the new tokens created to pass from the current saved point to the final updated points

    Methods inherited from class it.polimi.ingsw.am13.client.view.gui.ViewGUIController

    getScene, setNetworkHandler, setScene, setStage, switchToScene

    Methods inherited from class java.lang.Object

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

    • playersContainer

      private javafx.scene.layout.GridPane playersContainer
      Container for the labels displaying the players in game (to the left of the screen)
    • fieldScrollPane

      private javafx.scene.control.ScrollPane fieldScrollPane
      ScrollPane containing the field. For the scroll to work, the fieldContainer contained must be bigger than this container
    • fieldContainer

      private javafx.scene.layout.StackPane fieldContainer
      Container where to stack the cards to display for the player's field ImageView and Rectangle for card placed and available coords are added to this container for the field
    • actionLabel

      private javafx.scene.control.Label actionLabel
      Label displaying the current game action to perform
    • displayPlayerLabel

      private javafx.scene.control.Label displayPlayerLabel
      Label displaying the name of the player whose field is currently being displayed
    • turnsCounterLabel

      private javafx.scene.control.Label turnsCounterLabel
      Label for counter visible during final phase, displaying the number of turns left to the end of the game
    • turnsCounterBackground

      private javafx.scene.image.ImageView turnsCounterBackground
      Background image ofr counter of turns to the end of the game
    • plantCounterLabel

      private javafx.scene.control.Label plantCounterLabel
      Label for counter of plant resources in the field of displayPlayer
    • animalCounterLabel

      private javafx.scene.control.Label animalCounterLabel
      Label for counter of animal resources in the field of displayPlayer
    • fungusCounterLabel

      private javafx.scene.control.Label fungusCounterLabel
      Label for counter of fungus resources in the field of displayPlayer
    • manuscriptCounterLabel

      private javafx.scene.control.Label manuscriptCounterLabel
      Label for counter of manuscript resources in the field of displayPlayer
    • insectCounterLabel

      private javafx.scene.control.Label insectCounterLabel
      Label for counter of insect resources in the field of displayPlayer
    • quillCounterLabel

      private javafx.scene.control.Label quillCounterLabel
      Label for counter of quill resources in the field of displayPlayer
    • inkwellCounterLabel

      private javafx.scene.control.Label inkwellCounterLabel
      Label for counter of inkwell resources in the field of displayPlayer
    • scoreTrackerView

      private javafx.scene.image.ImageView scoreTrackerView
    • scoreTrackerContainer

      private javafx.scene.layout.StackPane scoreTrackerContainer
    • handCard0

      private javafx.scene.image.ImageView handCard0
    • flipButton0

      private javafx.scene.control.Button flipButton0
    • handCard1

      private javafx.scene.image.ImageView handCard1
    • flipButton1

      private javafx.scene.control.Button flipButton1
    • handCard2

      private javafx.scene.image.ImageView handCard2
    • flipButton2

      private javafx.scene.control.Button flipButton2
    • handObjective

      private javafx.scene.image.ImageView handObjective
    • pickablesContainer

      private javafx.scene.layout.Pane pickablesContainer
    • resDeck

      private javafx.scene.image.ImageView resDeck
    • resPick1

      private javafx.scene.image.ImageView resPick1
    • resPick2

      private javafx.scene.image.ImageView resPick2
    • gldDeck

      private javafx.scene.image.ImageView gldDeck
    • gldPick1

      private javafx.scene.image.ImageView gldPick1
    • gldPick2

      private javafx.scene.image.ImageView gldPick2
    • objDeck

      private javafx.scene.image.ImageView objDeck
    • commonObj1

      private javafx.scene.image.ImageView commonObj1
    • commonObj2

      private javafx.scene.image.ImageView commonObj2
    • chatChoice

      private javafx.scene.control.ChoiceBox<List<PlayerLobby>> chatChoice
    • chatArea

      private javafx.scene.control.TextArea chatArea
    • chatField

      private javafx.scene.control.TextField chatField
    • logArea

      private javafx.scene.control.TextArea logArea
      Area of non-editable text for showing logs
    • guideArea

      private javafx.scene.control.TextArea guideArea
    • soundsButton

      private javafx.scene.control.Button soundsButton
    • soundsVolSlider

      private javafx.scene.control.Slider soundsVolSlider
    • musicButton

      private javafx.scene.control.Button musicButton
    • musicVolSlider

      private javafx.scene.control.Slider musicVolSlider
    • chat

      private Chat chat
    • state

      private GameState state
      Game's state. Information about state of game are uniquely taken from here
    • thisPlayer

      private PlayerLobby thisPlayer
      Player associated to the client the GUI was created by
    • displayPlayer

      private PlayerLobby displayPlayer
      Player whose field and back of hand cards are currently being displayed
    • log

      private LogGUI log
      Handler of the logs
    • handCardSides

      private List<Side> handCardSides
      The sides on which each of the hand cards are being displayed
    • flowCardPlaced

      private boolean flowCardPlaced
      True if it is the turn of thisPlayer and he has played a card, false otherwise
    • attemptedToPlayCardHand

      private javafx.scene.image.ImageView attemptedToPlayCardHand
      The ImageView of the hand card thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    • attemptedToPlayFlipButton

      private javafx.scene.control.Button attemptedToPlayFlipButton
      The button used to flip the hand card thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    • attemptedToPlayCardField

      private javafx.scene.image.ImageView attemptedToPlayCardField
      The ImageView of the card on the field that thisPlayer has played, before he receives confirmation from the server of the fact that the card was played successfully
    • attemptedToPlayCardBox

      private javafx.scene.shape.Rectangle attemptedToPlayCardBox
      The card box in which thisPlayer has placed a card, before he receives confirmation from the server of the fact that the card was played successfully
    • handPlayable

      private List<CardPlayableIF> handPlayable
      The playable cards in the hand of displayPlayer
    • playersHandsPlayable

      private Map<PlayerLobby,List<CardPlayableIF>> playersHandsPlayable
      A map storing the playable cards in the hand of each player
    • handCards

      private List<javafx.scene.image.ImageView> handCards
      The images of the cards in the hand of displayPlayer
    • flipButtons

      private List<javafx.scene.control.Button> flipButtons
      The buttons to flip the hand cards of thisPlayer
    • playerNodes

      private Map<PlayerLobby,javafx.scene.Node> playerNodes
      A map associating to the nickname of each player the VBox in which his information is being displayed
    • counterLabels

      private Map<Resource,javafx.scene.control.Label> counterLabels
      A map associating each resource to its Label
    • initOverlay

      private javafx.scene.shape.Rectangle initOverlay
      Overlay rectangle for the init view
    • overlayWidthListener

      private javafx.beans.value.ChangeListener<Number> overlayWidthListener
      Listener for the main window's width used for the overlay in init and winner view
    • overlayHeightListener

      private javafx.beans.value.ChangeListener<Number> overlayHeightListener
      Listener for the main window's height used for the overlay in init and winner view
    • tokenImgs

      private final Map<PlayerLobby,javafx.scene.image.ImageView> tokenImgs
      Map associating each player to its token image in the score tracker
    • savedPoints

      private final Map<PlayerLobby,Integer> savedPoints
      Map associating each player to the current saved points, before a new eventual modification
    • tokenOffsetCoordinates

      private final Map<PlayerLobby,Double> tokenOffsetCoordinates
      Map associating each player to the current graphical x-offset for their token on the scroeboard, with respect to the main coordinates of their points. In fact, to show overlapped token, the image of a token could be placed with a slight offset
    • firstFieldScrollAdjustment

      private boolean firstFieldScrollAdjustment
      Flag indicating if the first scroll adjustment to center the starter card has already happened Hence it is set to true each time the displayPlayer changes
    • controllerInit

      private ViewGUIControllerInit controllerInit
      Controller for the initialization view
    • controllerWinner

      private ViewGUIControllerWinner controllerWinner
      Controller for the winner view
    • soundsOn

      private boolean soundsOn
      Flag indicating if sounds must be played
    • imageW

      private static final int imageW
      Entire width of the image of a card
      See Also:
    • imageH

      private static final int imageH
      Entire height of the image of a card
      See Also:
    • cornerX

      private static final int cornerX
      Width of a visible corner of the image of a card
      See Also:
    • cornerY

      private static final int cornerY
      Height of a visible corner of the image of a card
      See Also:
    • tokenDim

      private static final int tokenDim
      Width/Height of the tokens visible on top of the starter card on the field
      See Also:
    • xTranslToken

      private static final List<Double> xTranslToken
      Relative coordinates for x-positions of tokens on the score tracker
    • yTranslToken

      private static final List<Double> yTranslToken
      Relative coordinates for y-positions of tokens on the score tracker
    • TOKEN_X_OFFSET

      private static final double TOKEN_X_OFFSET
      Horizontal offset of overlapped tokens
      See Also:
    • tokenDimRel2x

      private static final double tokenDimRel2x
      Token dimension (square shape) relative to width (x) of the score tracker
      See Also:
    • THINKING_TIME

      private static final long THINKING_TIME
      Only for debug: delay for doing actions in SKIP_TURNS mode
      See Also:
    • musicTrackChoice

      private javafx.scene.control.ChoiceBox<String> musicTrackChoice
    • musicTracksMap

      public static final Map<String,String> musicTracksMap
      Map associating the strings shown in the choice box for the music tracks with the respective file name of the audio file. All audio files must be in /music dir
    • musicAlreadyStarted

      private boolean musicAlreadyStarted
      Flag indicating if the current background music track has begun or not
    • musicPlayer

      private javafx.scene.media.MediaPlayer musicPlayer
      Player of the background music
  • Constructor Details

    • ViewGUIControllerMatch

      public ViewGUIControllerMatch()
  • Method Details

    • init

      public void init(ViewGUIControllerInit controllerInit, ViewGUIControllerWinner controllerWinner, Chat chat)
      Initialization method, it must be called as first method before starting using the object. It sets all the visual elements and the internal state information
      Parameters:
      controllerInit - Controller for the initialization view. It has not to be already set
      controllerWinner - Controller for the winner view. It has not to be already set
      chat - Chat instance
    • setThisPlayer

      public void setThisPlayer(PlayerLobby thisPlayer)
      Method that sets the player
      Specified by:
      setThisPlayer in class ViewGUIController
      Parameters:
      thisPlayer - the player associated to this ViewGUIController
    • setGameState

      public void setGameState(GameState gameState)
      Method that sets the gameState
      Specified by:
      setGameState in class ViewGUIController
      Parameters:
      gameState - the representation of the state of the game
    • getSceneTitle

      public String getSceneTitle()
      Specified by:
      getSceneTitle in class ViewGUIController
      Returns:
      the title of the scene
    • showException

      public void showException(Exception e)
      Shows a generic exception in the view (specific exception could be handled in different ways, also depending on the phase or the state of game)
      Specified by:
      showException in class ViewGUIController
      Parameters:
      e - Exception to be shown
    • showPlayerDisconnected

      public void showPlayerDisconnected(PlayerLobby player)
      It shows that a player disconnected from an ongoing game by updating the player container
      Specified by:
      showPlayerDisconnected in class ViewGUIController
      Parameters:
      player - Player who disconnected
    • showPlayerReconnected

      public void showPlayerReconnected(PlayerLobby player)
      It shows that a player reconnected to an ongoing game by updating the player container
      Specified by:
      showPlayerReconnected in class ViewGUIController
      Parameters:
      player - Player who reconnected
    • forceCloseApp

      public void forceCloseApp()
      Force closing the app. It should be used to end the app for anomalous reasons
      Specified by:
      forceCloseApp in class ViewGUIController
    • showStartGame

      public void showStartGame()
      Show the start of the game by creating a semi transparent layer and displaying the init scene on top of it
    • showPlayedStarter

      public void showPlayedStarter(PlayerLobby player)
      Show that player his starting card by calling the corresponding method on ViewGUIControllerInit, displaying in the field , adding the corresponding log and displaying the logs
      Parameters:
      player - who played his starter card
    • showChosenPersonalObjective

      public void showChosenPersonalObjective(PlayerLobby player)
      Show that a player showed his personal objectiveby calling the corresponding method on ViewGUIControllerInit, adding the corresponding log and displaying the logs
      Parameters:
      player - who chose his personal objective
    • showInGame

      public void showInGame()
      Show that we reached the in game phase, by removed the init scene and the transparent overlay, adding the log message, updating the hand playable, field and players container
    • showPlayedCard

      public void showPlayedCard(PlayerLobby player, Coordinates coord)
      If the player is thisPlayer, set to true flowCardPlaced, make the pickable cards clickable and update actionLabel. Update playersHandsPlayable. If the player is displayPlayer, display the field and the hand playable (to update them)
      Parameters:
      player - who played the card
      coord - of the player where the card was played
    • showPickedCard

      public void showPickedCard(PlayerLobby player)
      Show that a card was picked by making the pickable cards not clickable, updating playersHandsPlayable and displaying the hand playable
      Parameters:
      player - who picked the card
    • showNextTurn

      public void showNextTurn()
      Make all the updates necessary to make it the turn of the next player
    • showFinalPhase

      public void showFinalPhase()
      Sho the logs, update the turnsCounterLabel
    • showUpdatePoints

      public void showUpdatePoints()
      Modifies all the elements on the view in order to update them with the final value and not to allow any other modifications.
    • showWinner

      public void showWinner()
      Creates a new layer over all the view, which closes after the first click of the mouse
    • showEndGame

      public void showEndGame()
    • flipCard

      private void flipCard(int i, javafx.scene.image.ImageView handCard)
      It flips the hand card by switching the corresponding value of handCardSides and then displaying the new side.
      Parameters:
      i - index of the handCard that needs to be flipped
      handCard - the handCard that needs to be flipped
    • displayHandPlayable

      private void displayHandPlayable()
      this method displays the hand of playable cards of displayPlayer If displayPlayer is thisPlayer, it prints the card on the front, adds the buttons to flip them and make them draggable if it is the turn of thisPlayer. Otherwise, it shows the cards on the back. Note that handPlayable is managed in such a way that the order of the cards in the hand does not change, but this is only the case as long as you do not change display player.
    • displayHandObjective

      public void displayHandObjective()
      Display the personal objective card
    • initPlayerContainer

      private void initPlayerContainer()
      Initialize the player container
    • switchToPlayer

      private void switchToPlayer(PlayerLobby displayPlayer)
      This method updates displayPlayer and displays his field and playable hand
      Parameters:
      displayPlayer - the player that needs to be displayed
    • playersContainerUpdateTurns

      private void playersContainerUpdateTurns()
      Updates player container labels representing the turn of the players. Every turn label is set to "waiting" except for the player currently playing, which will be set to "TURN".
    • playerContainerUpdateConnection

      private void playerContainerUpdateConnection(PlayerLobby player)
      Updates player container connection status of the player which has disconnected or reconnected.
      Parameters:
      player - Player which needs its connection status label to be updated
    • displayPickablesAndCommonObjs

      private void displayPickablesAndCommonObjs()
      Display the pickable cards and the common objectives
    • clearPickables

      private void clearPickables()
      Clear the pickable cards
    • makeDraggable

      private void makeDraggable(int handPlayableIndex, javafx.scene.image.ImageView imageView, javafx.scene.control.Button flipButton)
      It makes the card corresponding to the parameters draggable. When the drag is completed, it makes the card not visible and removes to possibility to drag all the cards in the hand.
      Parameters:
      handPlayableIndex - the index of the card that needs to be made draggable
      imageView - corresponding to the card that needs to be made draggable
    • displayField

      private void displayField()
      This method displays the field of displayPlayer, by displaying all the placed cards and adding boxes at each available coordinate.
    • addCardBox

      private void addCardBox(Coordinates coordinates, List<CardPlayableIF> finalHandPlayable)
      This method adds a box at the passed coordinates. If thisPlayer is displayPlayer, I make it possible to drag objects (playable cards) into the box. If it is not the turn of thisPlayer, the cards will not be draggable, so it is not necessary to change the action executed when objects are dragged into the box depending on the current player.
      Parameters:
      coordinates - of the field (as it is stored in the state) at which the box should be added
      finalHandPlayable - the playable cards of displayPlayer
    • adjustFieldContainerSize

      private void adjustFieldContainerSize()
      Adjust field container size to contain all the cards displayed in it. It checks the maximum extension of the elements in it, and if it does not exceed the fieldScrollPane current size, it sets the size of the fieldContainer to the double of the fieldScrollPane. If instead it exceeds, the size if that maximum extension doubled. Also, the scroll of the fieldScrollPane is adjusted, considering if it is the first time the adjustment happens for the displayed field (set to center of field) or if it must take into account the old value.
    • updateActionLabel

      private void updateActionLabel()
      Update the actionLabel's text, according to the current phase of the game flow for thisPlayer
    • onFieldZoomButtonAction

      public void onFieldZoomButtonAction()
      Method associated to the button for zooming in the field
    • onFieldDezoomButtonAction

      public void onFieldDezoomButtonAction()
      Method associated to the button for zooming out the field
    • onMouseWheelScroll

      public void onMouseWheelScroll(javafx.scene.input.ScrollEvent scrollEvent)
      Method associated to the scroll (CTRL + scroll of mouse wheel) to zoom/dezoom the field
      Parameters:
      scrollEvent - Event of the scroll
    • onClickResetFieldScroll

      public void onClickResetFieldScroll()
      Method associated to the button for resetting the scroll/zoom of the field
    • initScoreTracker

      private void initScoreTracker()
      Initializes the score tracker view and creates all the tokens as image views. Places all the tokens at the position 0
    • createTokenImage

      private javafx.scene.image.ImageView createTokenImage(PlayerLobby player)
      Creates the image for the color token of the given player
      Parameters:
      player - Player whose the color token images is to be generated
      Returns:
      Container of the image of the player's color token
    • createAndPositionTokenImage

      private javafx.scene.image.ImageView createAndPositionTokenImage(PlayerLobby player)
      Creates the image for the color token of the given player, and places it on the position 0 of the score tracker
      Parameters:
      player - Player whose the color token images is to be generated and placed
      Returns:
      Container of the image of the player's color token
    • updateTokenPositionRic

      private void updateTokenPositionRic(PlayerLobby player)
      Recursive creation and concatenation of the animation for the new tokens created to pass from the current saved point to the final updated points
      Parameters:
      player - Player whose token is to be animated
    • updateTokenPosition

      private void updateTokenPosition(PlayerLobby player)
      Updates the position of the token image on the score tracker, according to the actual points of the player. It animates the movement making the token pass through all the intermediate steps. If the points exceeds the maximum of the scoretracker, a new token is created starting from 0 again, so that the total points are obtained as the sum of the points where the old token and the new token are.
      Parameters:
      player - Player whose token is to be moved
    • createAnimationTokenMove

      private List<javafx.animation.PathTransition> createAnimationTokenMove(PlayerLobby player, int from, int to, List<PlayerLobby> animationPlayers)
      Creates and plays an animation of the given token moving on the scoretrakcer. The specified points must be the visible number on the scoretracker, and the token can move only forward
      Parameters:
      player - Player whose token is to be moved
      from - Points where to start from. Must be a number ≥0 and < 29
      to - Points where to arrive. Must be a number >from, so >0 and ≤29
      Returns:
      The transition animation (could be useful to add listeners...)
    • createAnimationTokenOffsetLess

      private javafx.animation.PathTransition createAnimationTokenOffsetLess(PlayerLobby player)
      Creates and plays an animation moving the token of the specified player of an 'offset less', if its token has an offset > 0. Updates the saved offset, too.
      Parameters:
      player - Player whose token is to be moved
    • displayCard

      private void displayCard(String id, Side side, javafx.scene.image.ImageView imageView)
      It opens the image corresponding to the passed id and side, adds it to the passed ImageView and then sets the height and width (they will always be the same since the only images that need to be displayed are cards). If necessary, it adapts the id (since many backs are identical, and all the backs of objective cards are identical, there is not a different image for each one of them)
      Parameters:
      id - of the card to be displayed
      side - of the card to be displayed
      imageView - in which the card should be displayed
    • showLastLogs

      private void showLastLogs()
      Updates the logArea to show the last non-shown log messages
    • playAudio

      private void playAudio(String fileName)
      Plays the specified audio file if audio is currently on, with volume indicated by soundsVolSlider The file must be in relative path /sounds with respect to the fxml file
      Parameters:
      fileName - Name of the audio file, comprehensive of the extension. The file must be located in sounds directory of the project
    • playTransitionAppearLeftRight

      private void playTransitionAppearLeftRight(javafx.scene.Node node, double totWidth)
      Creates and plays a transition making the given node appearing with the slide of a clip from left to right
      Parameters:
      node - Node to make appear
      totWidth - Width of the node (total movement the clip must do)
    • onQuitGame

      private void onQuitGame()
    • onRestartGame

      private void onRestartGame()
      Action performed to return to homepage, actually disconnecting voluntarily from the game. For simplicity, it completely restarts the app, and works only if it was launch via jar
    • selectSoundsImage

      private void selectSoundsImage()
      Sets the right image for sounds button in settings
    • onSoundButtonClick

      public void onSoundButtonClick()
      Handler of the click of the sound button in settings. It enables/disables the sound effects when playing, changing the image for the button
    • selectMusicImage

      private void selectMusicImage(boolean playing)
      Sets the right image for background music button in settings
      Parameters:
      playing - True if the player is set to be playing, false otherwise
    • onMusicButtonClick

      public void onMusicButtonClick()
      Handler of the click of the music button in settings. It plays or pauses the background music. If the music is played from the beginning, it does it with a fade-in sound effect. It also changes the button icon and disables the track choice box if the music is playing
    • startPlayingMusic

      private void startPlayingMusic()
      Starts playing the current track selected in the music track choice box. If the track is played for the first time, it does it with a fade-in sound effect
    • changeMusicToPlay

      private void changeMusicToPlay(String trackKey)
      It changes the current track chosen for the player of background music. If the player is currently playing, it is paused. At the end the player is not activated
      Parameters:
      trackKey - Track to choose for the player
    • initMusicSettings

      private void initMusicSettings()
      It initializes the sounds and music section in settings
    • setChat

      public void setChat(Chat chat)
      Sets the chat, and initializes chatChoices with the valid choices.
      Parameters:
      chat - of thisPlayer in this match
    • onClickSendMessage

      public void onClickSendMessage()
      When the button is clicked, if there is a message and a receiver has been selected, a chat message is sent.
    • onChatTextFieldKeyPressed

      public void onChatTextFieldKeyPressed(javafx.scene.input.KeyEvent event)
      When enter is pressed on the keyboard, the message is sent
      Parameters:
      event - a key is pressed on the keyboard
    • onClickShowRulebook

      public void onClickShowRulebook()
    • showChatMessage

      public void showChatMessage(PlayerLobby sender, List<PlayerLobby> receivers)
      If the message belongs to the chat that is currently being selected, it shows it.
      Parameters:
      sender - of the message
      receivers - of the message
    • showChatWith

      private void showChatWith(List<PlayerLobby> receivers)
      Clears the chat area and replaces it with all the messages between thisPlayer and the passed parameter
      Parameters:
      receivers - list of players that thisPlayer is chatting with