Package viewModel

Class ViewModel

java.lang.Object
viewModel.ViewModel

public class ViewModel extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.StringProperty
     
    javafx.beans.property.IntegerProperty
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.StringProperty
     
    javafx.beans.property.IntegerProperty
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.ObjectProperty<String>
     
    javafx.beans.property.IntegerProperty
     
    List<javafx.beans.property.StringProperty>
     
    List<javafx.beans.property.IntegerProperty>
     
    javafx.beans.property.StringProperty
     
    javafx.beans.property.IntegerProperty
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    javafx.beans.property.ObjectProperty<javafx.scene.control.Button>
     
    javafx.beans.property.ObjectProperty<javafx.scene.control.Button>
     
    javafx.beans.property.ObjectProperty<javafx.scene.control.Button>
     
    javafx.beans.property.StringProperty
     
    javafx.beans.property.IntegerProperty
     
    javafx.beans.property.ObjectProperty<javafx.scene.image.Image>
     
    List<javafx.beans.property.ObjectProperty<javafx.scene.image.Image>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    The ViewModel function is the constructor of the ViewModel class.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.beans.property.ObjectProperty<String>
    The getImagePath function returns the imagePath property.
    The getModel function returns the GameManager object that is being used by the controller.
    void
    The setModel function is used to set the model of the view.
    void
    The updateBoard function is called whenever the board needs to be updated.
    void
    The updateButtons function is called whenever the game state changes.
    void
    The updatePlayerNames function updates the player names in the GUI.
    void
    The updatePlayerScores function updates the player scores in the GUI.
    void
    The updatePlayerTiles function is used to update the tiles that are displayed on the screen.
    void
    The updateViewProperties function updates the view properties of the game.

    Methods inherited from class java.lang.Object

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

    • playerId

      public javafx.beans.property.IntegerProperty playerId
    • firstPlayerName

      public javafx.beans.property.StringProperty firstPlayerName
    • secondPlayerName

      public javafx.beans.property.StringProperty secondPlayerName
    • thirdPlayerName

      public javafx.beans.property.StringProperty thirdPlayerName
    • fourthPlayerName

      public javafx.beans.property.StringProperty fourthPlayerName
    • firstPlayerScore

      public javafx.beans.property.IntegerProperty firstPlayerScore
    • secondPlayerScore

      public javafx.beans.property.IntegerProperty secondPlayerScore
    • thirdPlayerScore

      public javafx.beans.property.IntegerProperty thirdPlayerScore
    • fourthPlayerScore

      public javafx.beans.property.IntegerProperty fourthPlayerScore
    • firstTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> firstTile
    • secondTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> secondTile
    • thirdTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> thirdTile
    • fourthTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> fourthTile
    • fifthTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> fifthTile
    • sixTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> sixTile
    • sevenTile

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> sevenTile
    • skipTurn

      public javafx.beans.property.ObjectProperty<javafx.scene.control.Button> skipTurn
    • submit

      public javafx.beans.property.ObjectProperty<javafx.scene.control.Button> submit
    • swap

      public javafx.beans.property.ObjectProperty<javafx.scene.control.Button> swap
    • tiles

      public List<javafx.beans.property.ObjectProperty<javafx.scene.image.Image>> tiles
    • playersNames

      public List<javafx.beans.property.StringProperty> playersNames
    • playersScores

      public List<javafx.beans.property.IntegerProperty> playersScores
    • imagePath

      public javafx.beans.property.ObjectProperty<String> imagePath
  • Constructor Details

    • ViewModel

      public ViewModel()
      The ViewModel function is the constructor of the ViewModel class. It initializes all the properties that are used in this class, and it also adds them to their respective lists.
  • Method Details

    • setModel

      public void setModel(GameManager model)
      The setModel function is used to set the model of the view.
      Parameters:
      model - model Set the model for this view
    • getImagePath

      public javafx.beans.property.ObjectProperty<String> getImagePath()
      The getImagePath function returns the imagePath property.
      Returns:
      A stringProperty
    • updateViewProperties

      public void updateViewProperties()
      The updateViewProperties function updates the view properties of the game. It calls all the update functions for each property that needs to be updated.
    • updatePlayerNames

      public void updatePlayerNames()
      The updatePlayerNames function updates the player names in the GUI. It is called whenever a new player joins or leaves, and when a game starts.
    • updatePlayerScores

      public void updatePlayerScores()
      The updatePlayerScores function updates the player scores in the GUI. It is called whenever a player's score changes, and it updates all the players' scores.
    • updatePlayerTiles

      public void updatePlayerTiles()
      The updatePlayerTiles function is used to update the tiles that are displayed on the screen. It does this by iterating through all the tiles in a player's hand and setting their image to be an image of that tile. This function is called whenever a player makes a move, or when they draw new tiles from the bag. The reason it uses Platform.runLater() is because it needs to run on JavaFx's thread, not its own thread (which would cause errors). This function also checks if there are any null values in order to prevent errors from occurring when players leave mid-game and their data
    • updateBoard

      public void updateBoard()
      The updateBoard function is called whenever the board needs to be updated. This function will update the imagePath property of each tile in the gameBoard, which will then cause a change listener to fire and update all the images on screen.
    • updateButtons

      public void updateButtons()
      The updateButtons function is called whenever the game state changes. It updates the visibility of buttons on the screen depending on whether it is a player's turn, and if so, which player's turn it is.
    • getModel

      public GameManager getModel()
      The getModel function returns the GameManager object that is being used by the controller.
      Returns:
      The model