Class LudoMenuController
java.lang.Object
edu.ntnu.idi.idatt.controller.common.MenuController
edu.ntnu.idi.idatt.controller.ludo.LudoMenuController
- All Implemented Interfaces:
ButtonClickObserver
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:
-
Field Summary
Fields inherited from class edu.ntnu.idi.idatt.controller.common.MenuController
boardFactory, boardVariants, currentBoardIndex, DEFAULT_BOARD_INDEX, logger, menuView, onBackToGameSelection, onCreateBoard, onStartGame
-
Constructor Summary
ConstructorsConstructorDescriptionLudoMenuController
(MenuView view) Constructs aLudoMenuController
with the specified menu view. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the list of players configured in the menu, creatingLudoPlayer
instances.protected void
Initializes the menu view with settings specific to Ludo.protected void
Loads the available Ludo board variants (Classic, Small, Large) using theLudoBoardFactory
and stores them in theboardVariants
map.void
loadPlayersFromFile
(String filePath) Loads player configurations from a specified file path and updates the menu view.Methods inherited from class edu.ntnu.idi.idatt.controller.common.MenuController
handleNextBoard, handlePreviousBoard, onButtonClicked, onButtonClickedWithParams, savePlayersToFile, setBoardFactory, setOnBackToGameSelection, setOnCreateBoard, setOnStartGame
-
Constructor Details
-
LudoMenuController
Constructs aLudoMenuController
with the specified menu view. Initializes the board factory toLudoBoardFactory
and sets up the menu view with Ludo-specific configurations.- Parameters:
view
- TheMenuView
that this controller will manage.
-
-
Method Details
-
getPlayers
Retrieves the list of players configured in the menu, creatingLudoPlayer
instances.- Specified by:
getPlayers
in classMenuController
- Returns:
- A list of
Player
objects, specificallyLudoPlayer
s, 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 classMenuController
-
loadPlayersFromFile
Loads player configurations from a specified file path and updates the menu view. This implementation ensures that onlyLudoPlayer
instances are imported. If other player types are found, an error is shown.- Overrides:
loadPlayersFromFile
in classMenuController
- 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 theLudoBoardFactory
and stores them in theboardVariants
map.- Specified by:
loadBoardsFromFactory
in classMenuController
-