java.lang.Object
viewModel.ViewModel
-
Field Summary
FieldsModifier and TypeFieldDescriptionjavafx.beans.property.ObjectProperty<javafx.scene.image.Image>javafx.beans.property.StringPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.ObjectProperty<javafx.scene.image.Image>javafx.beans.property.StringPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.ObjectProperty<javafx.scene.image.Image>javafx.beans.property.ObjectProperty<String>javafx.beans.property.IntegerPropertyList<javafx.beans.property.StringProperty>List<javafx.beans.property.IntegerProperty>javafx.beans.property.StringPropertyjavafx.beans.property.IntegerPropertyjavafx.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.StringPropertyjavafx.beans.property.IntegerPropertyjavafx.beans.property.ObjectProperty<javafx.scene.image.Image>List<javafx.beans.property.ObjectProperty<javafx.scene.image.Image>> -
Constructor Summary
ConstructorsConstructorDescriptionThe ViewModel function is the constructor of the ViewModel class. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ObjectProperty<String>The getImagePath function returns the imagePath property.getModel()The getModel function returns the GameManager object that is being used by the controller.voidsetModel(GameManager model) The setModel function is used to set the model of the view.voidThe updateBoard function is called whenever the board needs to be updated.voidThe updateButtons function is called whenever the game state changes.voidThe updatePlayerNames function updates the player names in the GUI.voidThe updatePlayerScores function updates the player scores in the GUI.voidThe updatePlayerTiles function is used to update the tiles that are displayed on the screen.voidThe updateViewProperties function updates the view properties of the game.
-
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
-
playersNames
-
playersScores
-
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
The setModel function is used to set the model of the view.- Parameters:
model- model Set the model for this view
-
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
The getModel function returns the GameManager object that is being used by the controller.- Returns:
- The model
-