Class BoardCreatorController

java.lang.Object
edu.ntnu.idi.idatt.controller.common.BoardCreatorController
All Implemented Interfaces:
ButtonClickObserver
Direct Known Subclasses:
LadderGameBoardCreatorController, LudoBoardCreatorController

public abstract class BoardCreatorController extends Object implements ButtonClickObserver
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 Details

    • logger

      protected static final org.slf4j.Logger logger
    • view

      protected final BoardCreatorView view
    • boardPane

      protected final BoardStackPane boardPane
    • onBackToMenu

      protected Runnable onBackToMenu
      Runnable action to execute when the "back to menu" event is triggered.
    • boardFactory

      protected BoardFactory boardFactory
    • board

      protected Board board
  • Constructor Details

    • BoardCreatorController

      public BoardCreatorController(BoardCreatorView view)
      Constructs a BoardCreatorController with the specified view.
      Parameters:
      view - The BoardCreatorView 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

      protected abstract void handleImportBoard(Map<String,Object> params)
      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

      protected abstract void handleSaveBoard(Map<String,Object> params)
      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

      public void onButtonClicked(String buttonId)
      Handles button click events without parameters. Delegates to specific handlers based on the button ID.
      Specified by:
      onButtonClicked in interface ButtonClickObserver
      Parameters:
      buttonId - The ID of the button that was clicked.
    • onButtonClickedWithParams

      public void onButtonClickedWithParams(String buttonId, Map<String,Object> params)
      Handles button click events with parameters. Delegates to specific handlers based on the button ID.
      Specified by:
      onButtonClickedWithParams in interface ButtonClickObserver
      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 an onBackToMenu runnable is set, it will be executed.
    • setOnBackToMenu

      public void setOnBackToMenu(Runnable onBackToMenu)
      Sets the action to be performed when the "back to menu" event is triggered.
      Parameters:
      onBackToMenu - The Runnable to execute.