Class LudoBoardCreatorController
java.lang.Object
edu.ntnu.idi.idatt.controller.common.BoardCreatorController
edu.ntnu.idi.idatt.controller.ludo.LudoBoardCreatorController
- All Implemented Interfaces:
ButtonClickObserver
LudoBoardCreatorController.
Controller responsible for the logic behind creating and editing LudoGameBoard
s.
It extends BoardCreatorController
and manages interactions with a
LudoBoardCreatorView
.
This controller handles tasks such as initializing the Ludo board with a default size, updating the board size based on user input, and saving/importing Ludo board configurations. Unlike the ladder game board creator, it does not currently manage dynamic component placement, as Ludo boards have a more fixed structure.
- See Also:
-
Field Summary
Fields inherited from class edu.ntnu.idi.idatt.controller.common.BoardCreatorController
board, boardFactory, boardPane, logger, onBackToMenu, view
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aLudoBoardCreatorController
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
handleImportBoard
(Map<String, Object> params) Handles the import of a Ludo board configuration from a file.protected void
handleSaveBoard
(Map<String, Object> params) Handles saving the current Ludo board configuration to a file.protected void
Handles the action to update the Ludo board's size based on the value from the view's board size spinner.protected void
Initializes theBoardCreatorController.board
instance as a new, blankLudoGameBoard
using aLudoBoardFactory
with a default size (e.g., 15x15 or a similar standard).protected void
Initializes theLudoBoardCreatorView
.Methods inherited from class edu.ntnu.idi.idatt.controller.common.BoardCreatorController
handleBackToMenu, onButtonClicked, onButtonClickedWithParams, setOnBackToMenu
-
Constructor Details
-
LudoBoardCreatorController
Constructs aLudoBoardCreatorController
.- Parameters:
view
- TheBoardCreatorView
(expected to be aLudoBoardCreatorView
) associated with this controller.
-
-
Method Details
-
initializeBoard
protected void initializeBoard()Initializes theBoardCreatorController.board
instance as a new, blankLudoGameBoard
using aLudoBoardFactory
with a default size (e.g., 15x15 or a similar standard).- Specified by:
initializeBoard
in classBoardCreatorController
-
initializeBoardCreatorView
protected void initializeBoardCreatorView()Initializes theLudoBoardCreatorView
. Sets this controller as an observer to the view and initializes the view with the current Ludo board.- Specified by:
initializeBoardCreatorView
in classBoardCreatorController
-
handleUpdateGrid
protected void handleUpdateGrid()Handles the action to update the Ludo board's size based on the value from the view's board size spinner. Updates theBoardCreatorController.board
model and refreshes the grid display in theBoardCreatorController.boardPane
.- Specified by:
handleUpdateGrid
in classBoardCreatorController
-
handleImportBoard
Handles the import of a Ludo board configuration from a file. It attempts to create a board usingLudoBoardFactory
. If successful, it updates the internalBoardCreatorController.board
model and refreshes the view's input fields (name, description, board size) and the board display. Shows an error alert if the import fails or the file is invalid.- Specified by:
handleImportBoard
in classBoardCreatorController
- Parameters:
params
- A map containing the "path" (String) to the Ludo board file.
-
handleSaveBoard
Handles saving the current Ludo board configuration to a file. Updates the board model with values from the view's input fields (name, description) before saving. UsesLudoBoardFileHandlerGson
for serialization. Shows an info alert on success or an error alert on failure.- Specified by:
handleSaveBoard
in classBoardCreatorController
- Parameters:
params
- A map containing the "path" (String) to save the file to.
-