You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

  1. package net.hoo2.auth.labyrinth;
  2. /**
  3. * @brief
  4. * This class represents the game's player
  5. */
  6. class Player {
  7. /**
  8. * @name Accessor/Mutator interface
  9. * @note
  10. * Please consider not to use mutator interface. Its the abstraction killer :(
  11. * We have added a bit of logic however, in order to make it a bit more safe.
  12. */
  13. /** @{ */
  14. int getPlayerId () { return playerId; }
  15. String getName() { return name; }
  16. Board getBoard () { return board; }
  17. int getScore () { return score; }
  18. int getX() { return x; }
  19. int getY() { return y; }
  20. void setPlayerId(int id) { playerId = id; }
  21. void setName(String name) { this.name = name; }
  22. void setBoard (Board board){ this.board = board; }
  23. void setScore(int score) { this.score = score; }
  24. void setX(int x) {
  25. assert (x >= 0 && x< Session.boardSize) : "X(column) coordinate must be in the range [0, Session.boardSize)";
  26. this.x = x;
  27. }
  28. void setY(int y) {
  29. assert (y >= 0 && y< Session.boardSize) : "Y(row) coordinate must be in the range [0, Session.boardSize)";
  30. this.y = y;
  31. }
  32. /** @} */
  33. /** @name Class data */
  34. /** @{ */
  35. private int playerId; /**< The unique identifier of the player */
  36. private String name; /**< The name of the player */
  37. private Board board; /**< Reference to the session's boards */
  38. private int score; /**< The current score of the player */
  39. private int x; /**< The column coordinate of the player on the board */
  40. private int y; /**< The row coordinate of the player on the board */
  41. /** @} */
  42. }