Class BoardCreatorController
java.lang.Object
edu.ntnu.idi.idatt.controller.common.BoardCreatorController
- All Implemented Interfaces:
ButtonClickObserver
- Direct Known Subclasses:
LadderGameBoardCreatorController
,LudoBoardCreatorController
BoardCreatorController.
Abstract controller responsible for handling the logic of board creation views.
It manages interactions between the BoardCreatorView
and the underlying
board model, using a BoardFactory
to create Board
instances.
This controller also observes button clicks from the view and delegates actions to specific handler methods.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Board
protected BoardFactory
protected final BoardStackPane
protected static final org.slf4j.Logger
protected Runnable
Runnable action to execute when the "back to menu" event is triggered.protected final BoardCreatorView
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a BoardCreatorController with the specified view. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Handles the "back to menu" action.protected abstract void
handleImportBoard
(Map<String, Object> params) Handles the action to import a board using the provided parameters.protected abstract void
handleSaveBoard
(Map<String, Object> params) Handles the action to save the current board configuration using the provided parameters.protected abstract void
Handles the action to update the grid or board display.protected abstract void
Initializes the game board.protected abstract void
Initializes the board creator view.void
onButtonClicked
(String buttonId) Handles button click events without parameters.void
onButtonClickedWithParams
(String buttonId, Map<String, Object> params) Handles button click events with parameters.void
setOnBackToMenu
(Runnable onBackToMenu) Sets the action to be performed when the "back to menu" event is triggered.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
view
-
boardPane
-
onBackToMenu
Runnable action to execute when the "back to menu" event is triggered. -
boardFactory
-
board
-
-
Constructor Details
-
BoardCreatorController
Constructs a BoardCreatorController with the specified view.- Parameters:
view
- TheBoardCreatorView
associated with this controller.
-
-
Method Details
-
initializeBoard
protected abstract void initializeBoard()Initializes the game board. This method is intended to be implemented by subclasses to set up the initial state of the board. -
initializeBoardCreatorView
protected abstract void initializeBoardCreatorView()Initializes the board creator view. Subclasses should implement this method to configure the view components, such as setting up UI elements and attaching event listeners. -
handleUpdateGrid
protected abstract void handleUpdateGrid()Handles the action to update the grid or board display. Subclasses must implement this to define the specific behavior for refreshing or reconfiguring the board view. -
handleImportBoard
Handles the action to import a board using the provided parameters.- Parameters:
params
- A map of parameters required for importing the board, e.g., file path.
-
handleSaveBoard
Handles the action to save the current board configuration using the provided parameters.- Parameters:
params
- A map of parameters for saving the board, e.g., file path.
-
onButtonClicked
Handles button click events without parameters. Delegates to specific handlers based on the button ID.- Specified by:
onButtonClicked
in interfaceButtonClickObserver
- Parameters:
buttonId
- The ID of the button that was clicked.
-
onButtonClickedWithParams
Handles button click events with parameters. Delegates to specific handlers based on the button ID.- Specified by:
onButtonClickedWithParams
in interfaceButtonClickObserver
- Parameters:
buttonId
- The ID of the button that was clicked.params
- A map of parameters associated with the button click.
-
handleBackToMenu
protected void handleBackToMenu()Handles the "back to menu" action. If anonBackToMenu
runnable is set, it will be executed. -
setOnBackToMenu
Sets the action to be performed when the "back to menu" event is triggered.- Parameters:
onBackToMenu
- TheRunnable
to execute.
-