Package edu.ntnu.idi.idatt.model.player
Class LudoPlayer
java.lang.Object
edu.ntnu.idi.idatt.model.player.Player
edu.ntnu.idi.idatt.model.player.LudoPlayer
LudoPlayer.
Extends the Player
class to represent a player in a Ludo game.
Each Ludo player has a set of four LudoToken
s. This class provides
methods to access these tokens and to move them on the game board, updating
their status accordingly.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLudoPlayer
(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot) Constructs aLudoPlayer
with the specified name, color, token type, and bot status. -
Method Summary
Methods inherited from class edu.ntnu.idi.idatt.model.player.Player
getColorHex, getName, getPlayerTokenType, isBot, setBot, setColorHex, setName, setPlayerTokenType
-
Constructor Details
-
LudoPlayer
Constructs aLudoPlayer
with the specified name, color, token type, and bot status. Initializes the player with fourLudoToken
s, each with a unique ID from 1 to 4.- Parameters:
name
- The name of the player.colorHex
- The hexadecimal string representation of the player's color.playerTokenType
- The type of token the player uses.isBot
- A boolean indicating whether the player is a "robot" or not.
-
-
Method Details
-
getTokens
Returns the list ofLudoToken
s belonging to this player.- Returns:
- A list of
LudoToken
s.
-
getToken
Retrieves a specificLudoToken
by its ID.- Parameters:
tokenId
- The ID of the token to retrieve (1-4).- Returns:
- The
LudoToken
with the specified ID. - Throws:
IllegalArgumentException
- if no token with the given ID is found.
-
moveToken
Moves the token with the given id to a new tile and updates its status.- Parameters:
pieceId
- the ID of the token to movetile
- the new tile to move the token tostatus
- the new status of the token
-