Labyrinth
A labyrinth game assignment
net.hoo2.auth.labyrinth.Player Class Reference

This class represents the game's player. More...

Package Functions

Constructors
 Player (int id, String name, boolean champion, Board board, int row, int column)
 Create a new player and put him at the row-column coordinates. More...
 
 Player (int id, String name, boolean champion, Board board, int tileId)
 Create a new player and put him at the row-column coordinates. More...
 
Player main application interface
int [] move (int id)
 Player's move. More...
 
int playerTileId ()
 Utility to access player's tileID. More...
 
int playerRow ()
 Utility to access player's row position (row coordinate) More...
 
int playerCol ()
 Utility to access player's column position (column coordinate) More...
 
Accessor/Mutator interface
Note
Please consider not to use mutator interface. Its the abstraction killer :( We have added a bit of logic however, in order to make it a bit more safe.
int getPlayerId ()
 
String getName ()
 
Board getBoard ()
 
int getScore ()
 
int getX ()
 
int getY ()
 
void setPlayerId (int id)
 
void setName (String name)
 
void setBoard (Board board)
 
void setScore (int score)
 
void setX (int x)
 
void setY (int y)
 

Private Attributes

Class data
int playerId
 The unique identifier of the player. More...
 
String name
 The name of the player. More...
 
Board board
 Reference to the session's boards. More...
 
int score
 The current score of the player. More...
 
int x
 The column coordinate of the player on the board. More...
 
int y
 The row coordinate of the player on the board. More...
 
boolean champion
 Champion indicate a player who plays against the Minotaur. More...
 

Detailed Description

This class represents the game's player.

Definition at line 16 of file Player.java.

Constructor & Destructor Documentation

◆ Player() [1/2]

net.hoo2.auth.labyrinth.Player.Player ( int  id,
String  name,
boolean  champion,
Board  board,
int  row,
int  column 
)
package

Create a new player and put him at the row-column coordinates.

Parameters
idThe id of the player
nameThe name of the player
championFlag to indicate if a player is a champion
boardReference to the board of the game
rowThe row coordinate of initial player position
columnThe column coordinate of initial player's position

Definition at line 29 of file Player.java.

◆ Player() [2/2]

net.hoo2.auth.labyrinth.Player.Player ( int  id,
String  name,
boolean  champion,
Board  board,
int  tileId 
)
package

Create a new player and put him at the row-column coordinates.

Parameters
idThe id of the player
nameThe name of the player
championFlag to indicate if a player is a champion
boardReference to the board of the game
tileIdThe tileId coordinate of player's initial position

Definition at line 47 of file Player.java.

Member Function Documentation

◆ getBoard()

Board net.hoo2.auth.labyrinth.Player.getBoard ( )
package

Definition at line 117 of file Player.java.

◆ getName()

String net.hoo2.auth.labyrinth.Player.getName ( )
package

Definition at line 116 of file Player.java.

◆ getPlayerId()

int net.hoo2.auth.labyrinth.Player.getPlayerId ( )
package

Definition at line 115 of file Player.java.

◆ getScore()

int net.hoo2.auth.labyrinth.Player.getScore ( )
package

Definition at line 118 of file Player.java.

◆ getX()

int net.hoo2.auth.labyrinth.Player.getX ( )
package

Definition at line 119 of file Player.java.

◆ getY()

int net.hoo2.auth.labyrinth.Player.getY ( )
package

Definition at line 120 of file Player.java.

◆ move()

int [] net.hoo2.auth.labyrinth.Player.move ( int  id)
package

Player's move.

A player first throws a dice to get a random direction. Then checks if the direction is walkable. If it is, then goes to that tile and update player's data. If the player is a champion then he also picks up a possible supply from the tile.

Parameters
idThe id of the starting tile.
Returns
An array containing player's final position and possible supply of that position. The array format is:
  • int[0]: The tileId of the final player's position.
  • int[1]: The row of the final player's position.
  • int[2]: The column of the final player's position.
  • int[1]: The supplyId in case player picked one (Const.noSupply otherwise).

Definition at line 78 of file Player.java.

◆ playerCol()

int net.hoo2.auth.labyrinth.Player.playerCol ( )
package

Utility to access player's column position (column coordinate)

Definition at line 105 of file Player.java.

◆ playerRow()

int net.hoo2.auth.labyrinth.Player.playerRow ( )
package

Utility to access player's row position (row coordinate)

Definition at line 103 of file Player.java.

◆ playerTileId()

int net.hoo2.auth.labyrinth.Player.playerTileId ( )
package

Utility to access player's tileID.

Definition at line 101 of file Player.java.

◆ setBoard()

void net.hoo2.auth.labyrinth.Player.setBoard ( Board  board)
package

Definition at line 124 of file Player.java.

◆ setName()

void net.hoo2.auth.labyrinth.Player.setName ( String  name)
package

Definition at line 123 of file Player.java.

◆ setPlayerId()

void net.hoo2.auth.labyrinth.Player.setPlayerId ( int  id)
package

Definition at line 122 of file Player.java.

◆ setScore()

void net.hoo2.auth.labyrinth.Player.setScore ( int  score)
package

Definition at line 125 of file Player.java.

◆ setX()

void net.hoo2.auth.labyrinth.Player.setX ( int  x)
package

Definition at line 126 of file Player.java.

◆ setY()

void net.hoo2.auth.labyrinth.Player.setY ( int  y)
package

Definition at line 130 of file Player.java.

Member Data Documentation

◆ board

Board net.hoo2.auth.labyrinth.Player.board
private

Reference to the session's boards.

Definition at line 140 of file Player.java.

◆ champion

boolean net.hoo2.auth.labyrinth.Player.champion
private

Champion indicate a player who plays against the Minotaur.

Definition at line 144 of file Player.java.

◆ name

String net.hoo2.auth.labyrinth.Player.name
private

The name of the player.

Definition at line 139 of file Player.java.

◆ playerId

int net.hoo2.auth.labyrinth.Player.playerId
private

The unique identifier of the player.

Definition at line 138 of file Player.java.

◆ score

int net.hoo2.auth.labyrinth.Player.score
private

The current score of the player.

Definition at line 141 of file Player.java.

◆ x

int net.hoo2.auth.labyrinth.Player.x
private

The column coordinate of the player on the board.

Definition at line 142 of file Player.java.

◆ y

int net.hoo2.auth.labyrinth.Player.y
private

The row coordinate of the player on the board.

Definition at line 143 of file Player.java.


The documentation for this class was generated from the following file: