java.lang.Object
view.GameController
-
Constructor Summary
ConstructorsConstructorDescriptionThe GameController function is the main function that controls all the game's logic. -
Method Summary
Modifier and TypeMethodDescriptionvoidbindAll()voidvoidvoidexit()voidhandleHostAction(String action) The handleHostAction function is a function that handles the actions sent from the host.voidThe initializeBoardUpdateAction function is responsible for updating the board whenever a new image is selected.voidThe initializeHostAction function is called in the initialize function of the GameController class.voidThe initiatePlayerButton function creates the buttons that will be used in the game.voidThe initiatePlayerName function is used to create the labels for each player's name.voidThe initiatePlayerScore function creates the labels for each player's score.voidvoidvoidvoidsetViewSharedData(ViewSharedData viewSharedData) voidSkipTurn()voidvoidstart()voidSubmit()voidvoidThe toggleStartButton function is used to toggle the visibility of the startGame button.voidupdateBoardCellImage(String newAction) The updateBoardCellImage function is used to update the image of a cell on the board.
-
Constructor Details
-
GameController
public GameController()The GameController function is the main function that controls all the game's logic. It takes in a String word, an ArrayList<Integer> indexRow, and an ArrayList<Integer> indexCol as parameters. The GameController function then checks if the word is valid by calling on checkWord() from WordChecker class. If it is valid, it will call on updateBoard() from Board class to update board with new tiles and score for player who played that turn.
-
-
Method Details
-
initiatePlayerName
public void initiatePlayerName()The initiatePlayerName function is used to create the labels for each player's name. -
initiatePlayerScore
public void initiatePlayerScore()The initiatePlayerScore function creates the labels for each player's score. -
initiatePlayerButton
public void initiatePlayerButton()The initiatePlayerButton function creates the buttons that will be used in the game. -
toggleStartButton
public void toggleStartButton()The toggleStartButton function is used to toggle the visibility of the startGame button. This function is called when a game has ended, and it allows for another game to be started. -
initializeHostAction
public void initializeHostAction()The initializeHostAction function is called in the initialize function of the GameController class. It sets up a listener for changes to the messageFromHost property of a player object, which is used by players to communicate with each other and with their host. The listener calls handleHostAction when it detects that there has been an update to this property, passing along whatever new value was assigned to it as an argument. -
initializeBoardUpdateAction
public void initializeBoardUpdateAction()The initializeBoardUpdateAction function is responsible for updating the board whenever a new image is selected. It does this by binding the imagePath property to the viewSharedData's ViewModel's ImagePath property, and then adding a listener to that bound property. Whenever there is an update in that bound property, it calls updateBoardCellImage with whatever new value was passed into it as an argument. -
updateBoardCellImage
The updateBoardCellImage function is used to update the image of a cell on the board.- Parameters:
newAction- newAction Update the board cell image
-
handleHostAction
The handleHostAction function is a function that handles the actions sent from the host. The function receives an action string and performs a switch case on it, performing different actions depending on what action was received.- Parameters:
action- action Determine which action to take
-
bindAll
public void bindAll() -
bindButtons
public void bindButtons() -
Submit
- Throws:
IOException
-
challenge
public void challenge() -
exit
public void exit() -
SwapTiles
public void SwapTiles() -
SkipTurn
public void SkipTurn() -
squareClickHandler
public void squareClickHandler() -
start
- Throws:
IOException
-
sendStartToServer
public void sendStartToServer() -
loadScene
- Throws:
IOException
-
loadBoard
- Throws:
IOException
-