Class LudoMenuController

java.lang.Object
edu.ntnu.idi.idatt.controller.common.MenuController
edu.ntnu.idi.idatt.controller.ludo.LudoMenuController
All Implemented Interfaces:
ButtonClickObserver

public class LudoMenuController extends MenuController
LudoMenuController.

Extends MenuController to manage the Ludo game setup menu. It is responsible for initializing the menu view with Ludo-specific options, such as allowed player token types (typically circles for Ludo) and colors. It uses a LudoBoardFactory to create and provide different Ludo board variants (e.g., Classic, Small, Large).

This controller handles player configuration, including creating LudoPlayer instances from the menu input. It also defines the minimum and maximum number of players allowed for a Ludo game and supports loading player configurations from a file, ensuring only Ludo players are imported.

See Also:
  • Constructor Details

    • LudoMenuController

      public LudoMenuController(MenuView view)
      Constructs a LudoMenuController with the specified menu view. Initializes the board factory to LudoBoardFactory and sets up the menu view with Ludo-specific configurations.
      Parameters:
      view - The MenuView that this controller will manage.
  • Method Details

    • getPlayers

      protected List<Player> getPlayers()
      Retrieves the list of players configured in the menu, creating LudoPlayer instances.
      Specified by:
      getPlayers in class MenuController
      Returns:
      A list of Player objects, specifically LudoPlayers, based on the menu's player row configurations.
    • initializeMenuView

      protected void initializeMenuView()
      Initializes the menu view with settings specific to Ludo. This includes loading available Ludo board variants, setting a default selected board, and configuring the view with the game title, allowed token types, allowed colors, and min/max player counts for Ludo.
      Specified by:
      initializeMenuView in class MenuController
    • loadPlayersFromFile

      public void loadPlayersFromFile(String filePath)
      Loads player configurations from a specified file path and updates the menu view. This implementation ensures that only LudoPlayer instances are imported. If other player types are found, an error is shown.
      Overrides:
      loadPlayersFromFile in class MenuController
      Parameters:
      filePath - The path to the file containing player data.
      See Also:
    • loadBoardsFromFactory

      protected void loadBoardsFromFactory()
      Loads the available Ludo board variants (Classic, Small, Large) using the LudoBoardFactory and stores them in the boardVariants map.
      Specified by:
      loadBoardsFromFactory in class MenuController