Class LudoPlayer

java.lang.Object
edu.ntnu.idi.idatt.model.player.Player
edu.ntnu.idi.idatt.model.player.LudoPlayer

public class LudoPlayer extends Player
LudoPlayer.

Extends the Player class to represent a player in a Ludo game. Each Ludo player has a set of four LudoTokens. This class provides methods to access these tokens and to move them on the game board, updating their status accordingly.

See Also:
  • Constructor Details

    • LudoPlayer

      public LudoPlayer(String name, String colorHex, PlayerTokenType playerTokenType, boolean isBot)
      Constructs a LudoPlayer with the specified name, color, token type, and bot status. Initializes the player with four LudoTokens, 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

      public List<LudoToken> getTokens()
      Returns the list of LudoTokens belonging to this player.
      Returns:
      A list of LudoTokens.
    • getToken

      public LudoToken getToken(int tokenId)
      Retrieves a specific LudoToken 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

      public void moveToken(int pieceId, Tile tile, LudoToken.TokenStatus status)
      Moves the token with the given id to a new tile and updates its status.
      Parameters:
      pieceId - the ID of the token to move
      tile - the new tile to move the token to
      status - the new status of the token