Module it.polimi.ingsw.am13
Class ViewGUIControllerMatch
java.lang.Object
it.polimi.ingsw.am13.client.view.gui.ViewGUIController
it.polimi.ingsw.am13.client.view.gui.ViewGUIControllerMatch
Controller of 'Match' scene, where player can actually play the most of the game
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.control.Label
Label displaying the current game action to performprivate javafx.scene.control.Label
Label for counter of animal resources in the field of displayPlayerprivate 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 successfullyprivate 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 successfullyprivate 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 successfullyprivate 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 successfullyprivate 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
private ViewGUIControllerInit
Controller for the initialization viewprivate ViewGUIControllerWinner
Controller for the winner viewprivate static final int
Width of a visible corner of the image of a cardprivate static final int
Height of a visible corner of the image of a cardA map associating each resource to its Labelprivate PlayerLobby
Player whose field and back of hand cards are currently being displayedprivate javafx.scene.control.Label
Label displaying the name of the player whose field is currently being displayedprivate javafx.scene.layout.StackPane
Container where to stack the cards to display for the player's fieldImageView
andRectangle
for card placed and available coords are added to this container for the fieldprivate 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 changesprivate 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 thisPlayerprivate boolean
True if it is the turn of thisPlayer and he has played a card, false otherwiseprivate javafx.scene.control.Label
Label for counter of fungus resources in the field of displayPlayerprivate 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 displayPlayerThe sides on which each of the hand cards are being displayedprivate javafx.scene.image.ImageView
private List
<CardPlayableIF> The playable cards in the hand of displayPlayerprivate static final int
Entire height of the image of a cardprivate static final int
Entire width of the image of a cardprivate javafx.scene.shape.Rectangle
Overlay rectangle for the init viewprivate javafx.scene.control.Label
Label for counter of inkwell resources in the field of displayPlayerprivate javafx.scene.control.Label
Label for counter of insect resources in the field of displayPlayerprivate LogGUI
Handler of the logsprivate javafx.scene.control.TextArea
Area of non-editable text for showing logsprivate javafx.scene.control.Label
Label for counter of manuscript resources in the field of displayPlayerprivate boolean
Flag indicating if the current background music track has begun or notprivate javafx.scene.control.Button
private javafx.scene.media.MediaPlayer
Player of the background musicprivate javafx.scene.control.ChoiceBox
<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 viewprivate javafx.beans.value.ChangeListener
<Number> Listener for the main window's width used for the overlay in init and winner viewprivate javafx.scene.layout.Pane
private javafx.scene.control.Label
Label for counter of plant resources in the field of displayPlayerprivate Map
<PlayerLobby, javafx.scene.Node> A map associating to the nickname of each player the VBox in which his information is being displayedprivate javafx.scene.layout.GridPane
Container for the labels displaying the players in game (to the left of the screen)private Map
<PlayerLobby, List<CardPlayableIF>> A map storing the playable cards in the hand of each playerprivate javafx.scene.control.Label
Label for counter of quill resources in the field of displayPlayerprivate 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 modificationprivate javafx.scene.layout.StackPane
private javafx.scene.image.ImageView
private javafx.scene.control.Button
private boolean
Flag indicating if sounds must be playedprivate javafx.scene.control.Slider
private GameState
Game's state.private static final long
Only for debug: delay for doing actions in SKIP_TURNS modeprivate PlayerLobby
Player associated to the client the GUI was created byprivate static final double
Horizontal offset of overlapped tokensprivate static final int
Width/Height of the tokens visible on top of the starter card on the fieldprivate static final double
Token dimension (square shape) relative to width (x) of the score trackerprivate final Map
<PlayerLobby, javafx.scene.image.ImageView> Map associating each player to its token image in the score trackerprivate 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 gameprivate javafx.scene.control.Label
Label for counter visible during final phase, displaying the number of turns left to the end of the gameRelative coordinates for x-positions of tokens on the score trackerRelative coordinates for y-positions of tokens on the score trackerFields inherited from class it.polimi.ingsw.am13.client.view.gui.ViewGUIController
networkHandler, scene, stage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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
changeMusicToPlay
(String trackKey) It changes the current track chosen for the player of background music.private void
Clear the pickable cardsprivate 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 trackerprivate 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
createTokenImage
(PlayerLobby player) Creates the image for the color token of the given playerprivate 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 cardprivate 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 objectivesprivate 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 settingsprivate void
Initialize the player containerprivate 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 sentvoid
Method associated to the button for resetting the scroll/zoom of the fieldvoid
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 fieldvoid
Method associated to the button for zooming in the fieldvoid
onMouseWheelScroll
(javafx.scene.input.ScrollEvent scrollEvent) Method associated to the scroll (CTRL + scroll of mouse wheel) to zoom/dezoom the fieldvoid
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
Plays the specified audio file if audio is currently on, with volume indicated bysoundsVolSlider
The file must be in relative path /sounds with respect to the fxml fileprivate 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 rightprivate void
selectMusicImage
(boolean playing) Sets the right image for background music button in settingsprivate void
Sets the right image for sounds button in settingsvoid
Sets the chat, and initializes chatChoices with the valid choices.void
setGameState
(GameState gameState) Method that sets the gameStatevoid
setThisPlayer
(PlayerLobby thisPlayer) Method that sets the playervoid
showChatMessage
(PlayerLobby sender, List<PlayerLobby> receivers) If the message belongs to the chat that is currently being selected, it shows it.private void
showChatWith
(List<PlayerLobby> receivers) Clears the chat area and replaces it with all the messages between thisPlayer and the passed parametervoid
Show that a player showed his personal objectiveby calling the corresponding method onViewGUIControllerInit
, adding the corresponding log and displaying the logsvoid
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 theturnsCounterLabel
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 containerprivate void
Updates the logArea to show the last non-shown log messagesvoid
Make all the updates necessary to make it the turn of the next playervoid
showPickedCard
(PlayerLobby player) Show that a card was picked by making the pickable cards not clickable, updatingplayersHandsPlayable
and displaying the hand playablevoid
showPlayedCard
(PlayerLobby player, Coordinates coord) If the player isthisPlayer
, set to trueflowCardPlaced
, make the pickable cards clickable and updateactionLabel
.void
showPlayedStarter
(PlayerLobby player) Show that player his starting card by calling the corresponding method onViewGUIControllerInit
, displaying in the field , adding the corresponding log and displaying the logsvoid
showPlayerDisconnected
(PlayerLobby player) It shows that a player disconnected from an ongoing game by updating the player containervoid
showPlayerReconnected
(PlayerLobby player) It shows that a player reconnected to an ongoing game by updating the player containervoid
Show the start of the game by creating a semi transparent layer and displaying the init scene on top of itvoid
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 mouseprivate 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 handprivate void
Update the actionLabel's text, according to the current phase of the game flow for thisPlayerprivate void
updateTokenPosition
(PlayerLobby player) Updates the position of the token image on the score tracker, according to the actual points of the player.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 pointsMethods inherited from class it.polimi.ingsw.am13.client.view.gui.ViewGUIController
getScene, setNetworkHandler, setScene, setStage, switchToScene
-
Field Details
-
playersContainer
private javafx.scene.layout.GridPane playersContainerContainer for the labels displaying the players in game (to the left of the screen) -
fieldScrollPane
private javafx.scene.control.ScrollPane fieldScrollPaneScrollPane
containing the field. For the scroll to work, the fieldContainer contained must be bigger than this container -
fieldContainer
private javafx.scene.layout.StackPane fieldContainerContainer where to stack the cards to display for the player's fieldImageView
andRectangle
for card placed and available coords are added to this container for the field -
actionLabel
private javafx.scene.control.Label actionLabelLabel displaying the current game action to perform -
displayPlayerLabel
private javafx.scene.control.Label displayPlayerLabelLabel displaying the name of the player whose field is currently being displayed -
turnsCounterLabel
private javafx.scene.control.Label turnsCounterLabelLabel for counter visible during final phase, displaying the number of turns left to the end of the game -
turnsCounterBackground
private javafx.scene.image.ImageView turnsCounterBackgroundBackground image ofr counter of turns to the end of the game -
plantCounterLabel
private javafx.scene.control.Label plantCounterLabelLabel for counter of plant resources in the field of displayPlayer -
animalCounterLabel
private javafx.scene.control.Label animalCounterLabelLabel for counter of animal resources in the field of displayPlayer -
fungusCounterLabel
private javafx.scene.control.Label fungusCounterLabelLabel for counter of fungus resources in the field of displayPlayer -
manuscriptCounterLabel
private javafx.scene.control.Label manuscriptCounterLabelLabel for counter of manuscript resources in the field of displayPlayer -
insectCounterLabel
private javafx.scene.control.Label insectCounterLabelLabel for counter of insect resources in the field of displayPlayer -
quillCounterLabel
private javafx.scene.control.Label quillCounterLabelLabel for counter of quill resources in the field of displayPlayer -
inkwellCounterLabel
private javafx.scene.control.Label inkwellCounterLabelLabel 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
-
chatArea
private javafx.scene.control.TextArea chatArea -
chatField
private javafx.scene.control.TextField chatField -
logArea
private javafx.scene.control.TextArea logAreaArea 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
-
state
Game's state. Information about state of game are uniquely taken from here -
thisPlayer
Player associated to the client the GUI was created by -
displayPlayer
Player whose field and back of hand cards are currently being displayed -
log
Handler of the logs -
handCardSides
The sides on which each of the hand cards are being displayed -
flowCardPlaced
private boolean flowCardPlacedTrue if it is the turn of thisPlayer and he has played a card, false otherwise -
attemptedToPlayCardHand
private javafx.scene.image.ImageView attemptedToPlayCardHandThe 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 attemptedToPlayFlipButtonThe 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 attemptedToPlayCardFieldThe 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 attemptedToPlayCardBoxThe 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
The playable cards in the hand of displayPlayer -
playersHandsPlayable
A map storing the playable cards in the hand of each player -
handCards
The images of the cards in the hand of displayPlayer -
flipButtons
The buttons to flip the hand cards of thisPlayer -
playerNodes
A map associating to the nickname of each player the VBox in which his information is being displayed -
counterLabels
A map associating each resource to its Label -
initOverlay
private javafx.scene.shape.Rectangle initOverlayOverlay rectangle for the init view -
overlayWidthListener
Listener for the main window's width used for the overlay in init and winner view -
overlayHeightListener
Listener for the main window's height used for the overlay in init and winner view -
tokenImgs
Map associating each player to its token image in the score tracker -
savedPoints
Map associating each player to the current saved points, before a new eventual modification -
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 firstFieldScrollAdjustmentFlag 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
Controller for the initialization view -
controllerWinner
Controller for the winner view -
soundsOn
private boolean soundsOnFlag indicating if sounds must be played -
imageW
private static final int imageWEntire width of the image of a card- See Also:
-
imageH
private static final int imageHEntire height of the image of a card- See Also:
-
cornerX
private static final int cornerXWidth of a visible corner of the image of a card- See Also:
-
cornerY
private static final int cornerYHeight of a visible corner of the image of a card- See Also:
-
tokenDim
private static final int tokenDimWidth/Height of the tokens visible on top of the starter card on the field- See Also:
-
xTranslToken
Relative coordinates for x-positions of tokens on the score tracker -
yTranslToken
Relative coordinates for y-positions of tokens on the score tracker -
TOKEN_X_OFFSET
private static final double TOKEN_X_OFFSETHorizontal offset of overlapped tokens- See Also:
-
tokenDimRel2x
private static final double tokenDimRel2xToken dimension (square shape) relative to width (x) of the score tracker- See Also:
-
THINKING_TIME
private static final long THINKING_TIMEOnly for debug: delay for doing actions in SKIP_TURNS mode- See Also:
-
musicTrackChoice
-
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 musicAlreadyStartedFlag indicating if the current background music track has begun or not -
musicPlayer
private javafx.scene.media.MediaPlayer musicPlayerPlayer 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 setcontrollerWinner
- Controller for the winner view. It has not to be already setchat
- Chat instance
-
setThisPlayer
Method that sets the player- Specified by:
setThisPlayer
in classViewGUIController
- Parameters:
thisPlayer
- the player associated to thisViewGUIController
-
setGameState
Method that sets the gameState- Specified by:
setGameState
in classViewGUIController
- Parameters:
gameState
- the representation of the state of the game
-
getSceneTitle
- Specified by:
getSceneTitle
in classViewGUIController
- Returns:
- the title of the scene
-
showException
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 classViewGUIController
- Parameters:
e
- Exception to be shown
-
showPlayerDisconnected
It shows that a player disconnected from an ongoing game by updating the player container- Specified by:
showPlayerDisconnected
in classViewGUIController
- Parameters:
player
- Player who disconnected
-
showPlayerReconnected
It shows that a player reconnected to an ongoing game by updating the player container- Specified by:
showPlayerReconnected
in classViewGUIController
- 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 classViewGUIController
-
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
Show that player his starting card by calling the corresponding method onViewGUIControllerInit
, displaying in the field , adding the corresponding log and displaying the logs- Parameters:
player
- who played his starter card
-
showChosenPersonalObjective
Show that a player showed his personal objectiveby calling the corresponding method onViewGUIControllerInit
, 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
If the player isthisPlayer
, set to trueflowCardPlaced
, make the pickable cards clickable and updateactionLabel
. UpdateplayersHandsPlayable
. If the player isdisplayPlayer
, display the field and the hand playable (to update them)- Parameters:
player
- who played the cardcoord
- of the player where the card was played
-
showPickedCard
Show that a card was picked by making the pickable cards not clickable, updatingplayersHandsPlayable
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 theturnsCounterLabel
-
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 flippedhandCard
- 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
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
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 draggableimageView
- 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
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 addedfinalHandPlayable
- 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
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
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
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
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 movedfrom
- Points where to start from. Must be a number ≥0 and < 29to
- Points where to arrive. Must be a number>from
, so >0 and ≤29- Returns:
- The transition animation (could be useful to add listeners...)
-
createAnimationTokenOffsetLess
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
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 displayedside
- of the card to be displayedimageView
- in which the card should be displayed
-
showLastLogs
private void showLastLogs()Updates the logArea to show the last non-shown log messages -
playAudio
Plays the specified audio file if audio is currently on, with volume indicated bysoundsVolSlider
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 appeartotWidth
- 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
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
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
If the message belongs to the chat that is currently being selected, it shows it.- Parameters:
sender
- of the messagereceivers
- of the message
-
showChatWith
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
-