rolec
Class Player

java.lang.Object
  extended by rolec.Player
All Implemented Interfaces:
java.lang.Cloneable

public class Player
extends java.lang.Object
implements java.lang.Cloneable

This card represents a Player in the game of Frank's Zoo


Constructor Summary
Player(int i, AI a, GameHistory h)
          Constructs a new Player
 
Method Summary
 Player clone()
          Clones this player
 Player clone(AI a)
          Clones this player with a specific AI
 void dealCard(Card c)
          Deals a card to the player
 void endGame(boolean simulation)
           
 int[] getCards()
          Returns an array representing the player hand.
 GameHistory getHistory()
          Returns the GameHistory of the player
 int getID()
          Returns the ID of this player
 java.util.Vector getMoves(Move m)
          Returns all possible moves to be played in response to a specific move.
 int hasJoker()
          Returns the ID of the joker
 int numberOfCards()
          Returns the number of cards in the hand of the player
 boolean out()
          Indicates whether this player has played all of his cards
 void printHand()
          Prints the player hand
 Move selectMove(Move move, boolean simulation)
          Selects a move in response to a specific move
 java.lang.String toString()
          Returns a String representation of this Player
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Player

public Player(int i,
              AI a,
              GameHistory h)
Constructs a new Player

Parameters:
i - the player ID
a - the AI used by the player
h - the GameHistory
Method Detail

getID

public int getID()
Returns the ID of this player

Returns:
the ID of this player

getHistory

public GameHistory getHistory()
Returns the GameHistory of the player

Returns:
the GameHistory of the player

dealCard

public void dealCard(Card c)
Deals a card to the player

Parameters:
c - the card dealt to the player

numberOfCards

public int numberOfCards()
Returns the number of cards in the hand of the player

Returns:
the number of cards in the hand of the player

getCards

public int[] getCards()
Returns an array representing the player hand. Each slot in the array represents one type of card (the number of the slot equals the ID of the card). The integer in the slot indicates the number of cards of the player is holding of this specific type of card. For instance, if int[5] = 3, then the player is holding 3 cards with ID 5.

Returns:
an array representing the player hand

out

public boolean out()
Indicates whether this player has played all of his cards

Returns:
true if a player has played all of his cards; false otherwise

printHand

public void printHand()
Prints the player hand


hasJoker

public int hasJoker()
Returns the ID of the joker

Returns:
the ID of the joker. If the player has no joker or there is no joker in the deck, -1 is returned

getMoves

public java.util.Vector getMoves(Move m)
Returns all possible moves to be played in response to a specific move. Possible moves are: (a) passing, (b) playing cards of the same type, but one more than was played before, (c) playing an equal number of predators.

Parameters:
m - the move to respond to
Returns:
a Vector containing all possible moves to be played in response to the specified move

selectMove

public Move selectMove(Move move,
                       boolean simulation)
Selects a move in response to a specific move

Parameters:
move - the move to respond to
Returns:
the selected move in response to the specified move

toString

public java.lang.String toString()
Returns a String representation of this Player

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this Player

clone

public Player clone()
Clones this player

Overrides:
clone in class java.lang.Object
Returns:
a cloned instance of this Player instance

endGame

public void endGame(boolean simulation)

clone

public Player clone(AI a)
Clones this player with a specific AI

Parameters:
a - the AI of the cloned player
Returns:
a cloned instance of this Player instance with specified AI