game
Class Player

java.lang.Object
  extended by game.Player
All Implemented Interfaces:
java.lang.Comparable<Player>
Direct Known Subclasses:
DoylesPlayer

public class Player
extends java.lang.Object
implements java.lang.Comparable<Player>

Contains all information about the current state of a player.
"Note: this class has a natural ordering that is inconsistent with equals."

Author:
Witthold/Korol

Field Summary
private  int bet
          Amount of money the player has currently put in the pot
private  int cashAtStartOfHand
          Amount of cash the player had at the beginning of the hand
protected  int cashCurrent
          Current cash (current bet is already subtracted)
protected  int cashInit
          Buy in or if it is doyle's game stack size
private  int currentPosition
          Position in this hand (0: first player behind the button; 1: second player behind the button; ...)
private  boolean folded
          If the player is folded
private  Card[] holeCards
          Hole cards of the player if they are known
private  int initPosition
          Position of player in the first hand (0: first player behind the button; 1: second player behind the button; ...)
private  java.lang.String name
          Name of the player
 
Constructor Summary
Player(java.lang.String name, int money)
          Creates a new player with the given name.
 
Method Summary
 void addBet(int bet)
          Adds the given amount of money to the own bet and decreases the current cash accordingly
 void addCash(int amount)
          Adds the given amount to the player's current cash.
 void applyAction(Action action)
          Applies action to the player.
 int compareTo(Player player)
          Compares the player to another by the profit of the players.
 void fold()
          Marks the player as folded.
 int getCashAtStartOfHand()
           
 int getCurrentBet()
           
 int getCurrentCash()
           
 int getCurrentPosition()
           
 Card[] getHoleCards()
           
 int getInitCash()
           
 int getInitPosition()
           
 java.lang.String getName()
           
 boolean isActive()
          Returns if the player isn't folded AND isn't all in.
 boolean isAllIn()
          Returns if the player's current cash is equals 0.
 boolean isFolded()
          Returns if the player is folded
 void printPlayerData()
          Prints the player's data to the console.
 void reset()
          Resets the player for a new hand.
 void setCashAtStartOfHand(int cash)
           
 void setCurrentPosition(int position)
           
 void setHoleCards(Card[] cards)
           
 void setInitPosition(int initPosition)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name
Name of the player


cashInit

protected int cashInit
Buy in or if it is doyle's game stack size


initPosition

private int initPosition
Position of player in the first hand (0: first player behind the button; 1: second player behind the button; ...)


cashAtStartOfHand

private int cashAtStartOfHand
Amount of cash the player had at the beginning of the hand


cashCurrent

protected int cashCurrent
Current cash (current bet is already subtracted)


currentPosition

private int currentPosition
Position in this hand (0: first player behind the button; 1: second player behind the button; ...)


bet

private int bet
Amount of money the player has currently put in the pot


folded

private boolean folded
If the player is folded


holeCards

private Card[] holeCards
Hole cards of the player if they are known

Constructor Detail

Player

public Player(java.lang.String name,
              int money)
Creates a new player with the given name. Initial & current cash are set accordingly.

Parameters:
name - players name
money - initial cash of the player
Method Detail

getName

public java.lang.String getName()
Returns:
The player's name

setInitPosition

public void setInitPosition(int initPosition)
Parameters:
initPosition - The position of the player in the first hand (0: first player behind the button; 1: second player behind the button; ...)

getInitPosition

public int getInitPosition()
Returns:
The position of the player in the first hand (0: first player behind the button; 1: second player behind the button; ...)

setCashAtStartOfHand

public void setCashAtStartOfHand(int cash)
Parameters:
cash - Amount of cash at the beginning of the hand

getCashAtStartOfHand

public int getCashAtStartOfHand()
Returns:
Amount of cash at the beginning of the hand

setCurrentPosition

public void setCurrentPosition(int position)
Parameters:
position - Position of the player in this hand (0: first player behind the button; 1: second player behind the button; ...)

getCurrentPosition

public int getCurrentPosition()
Returns:
Position of the player in this hand (0: first player behind the button; 1: second player behind the button; ...)

getCurrentCash

public int getCurrentCash()
Returns:
Current amount of cash the player has left. Current bets are not included.

addBet

public void addBet(int bet)
Adds the given amount of money to the own bet and decreases the current cash accordingly

Parameters:
bet - Amount of bet increasing

getCurrentBet

public int getCurrentBet()
Returns:
The total amount set by the player in this hand

setHoleCards

public void setHoleCards(Card[] cards)
Parameters:
cards - The hole cards of the player

getHoleCards

public Card[] getHoleCards()
Returns:
The hole cards of the player (or null if they aren't set)

isActive

public boolean isActive()
Returns if the player isn't folded AND isn't all in.

Returns:
true if player is active; false if player is folded or all-in

isAllIn

public boolean isAllIn()
Returns if the player's current cash is equals 0.

Returns:
true if the player is all-in

isFolded

public boolean isFolded()
Returns if the player is folded

Returns:
true if the player is folded

reset

public void reset()
Resets the player for a new hand.


applyAction

public void applyAction(Action action)
Applies action to the player. (Sets him folded or applies the money change)

Parameters:
action - The action which is to be applied

addCash

public void addCash(int amount)
Adds the given amount to the player's current cash.

Parameters:
amount - Amount of cash which is to be added

fold

public void fold()
Marks the player as folded.


compareTo

public int compareTo(Player player)
Compares the player to another by the profit of the players.

Specified by:
compareTo in interface java.lang.Comparable<Player>

printPlayerData

public void printPlayerData()
Prints the player's data to the console.


getInitCash

public int getInitCash()
Returns:
The amount of cash the player had have at the begin of the competition