Class PlayerFactory
java.lang.Object
edu.ntnu.idi.idatt.factory.player.PlayerFactory
Factory class for creating Player objects.
This class provides methods for creating Player objects based on predefined variants. Player objects can be loaded/created from an external file, or from hardcoded variants in this factory class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Player
createLadderGamePlayer
(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot) Creates a single LadderGame player with the given name and colorHex.static Player
createLudoPlayer
(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot) Creates a single Ludo player with the given name and colorHex.createPlayersFromFile
(String filePath) Creates a list of Player objects by reading from the given CSV file.
-
Method Details
-
createPlayersFromFile
Creates a list of Player objects by reading from the given CSV file.- Parameters:
filePath
- The path to the CSV file.- Returns:
- A List of Player objects parsed from the file.
- Throws:
IOException
- if an error occurs while reading the file.
-
createLadderGamePlayer
public static Player createLadderGamePlayer(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot) Creates a single LadderGame player with the given name and colorHex.- Parameters:
name
- The player's name.colorHex
- The player's color in hex (e.g. "#FF0000").playerTokenType
- The type of player token to use.isBot
- Whether the player is a bot or not.- Returns:
- A new LadderGamePlayer instance with the given attributes.
-
createLudoPlayer
public static Player createLudoPlayer(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot) Creates a single Ludo player with the given name and colorHex.- Parameters:
name
- The player's name.colorHex
- The player's color in hex (e.g. "#FF0000").playerTokenType
- The type of player token to use.isBot
- Whether the player is a bot or not.- Returns:
- A new LudoPlayer instance with the given attributes.
-