Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## glassfrog.players
Class Player

    java.lang.Object
      glassfrog.players.Player

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable<Player>

Direct Known Subclasses:
  AAAIPlayer, RandomPlayer, SocketPlayer, StringPlayer

    public abstract class Player

extends java.lang.Object
implements java.lang.Comparable<Player>, java.io.Serializable

The Player class represents the players in the game. They are given attribures such as thier current bet, score, how much they have commited to the pot, thier seat, hand rank, stack size. They also keep track of the actions of the player, such as if the player has acted in a particular round or if they have folded in a hand The Player class is also responsible for keeping track of the socket to which each player connects (The Buffered reader and the Print Writer of each as well)

Author:
  jdavidso
See Also:
  Serialized Form

Field Summary
`private boolean` | `acted`
`private int` | `buyIn`
`private java.lang.String` | `cardString`
`private int` | `currentBet`
`private boolean` | `folded`
`private int` | `handRank`
`private java.lang.String` | `handString`
`private java.lang.String` | `name`
`private int` | `position`
`private int` | `score`
`private int` | `seat`
`private int` | `stack`
`private int` | `totalCommitedToPot`

Constructor Summary
`Player()` Default Player constructor
`Player(java.lang.String name, int buyIn)` A constructor for a Player object that only takes a name, buyIn

Method Summary
`void` | `addToScore(int score)` Add a value to the player's score
`int` | `bet(int betSize)` Make a bet of the passed in size.
`int` | `call(int currentBet)` Have the player call the current bet This will take the player's current bet and figure out how much more the player has to bet to call, make that bet then return the amount it cost to make the bet since there will be some cases where a call will be more that the player's stack and the player will then be all in for less than the amount needed to call
`int` | `compareTo(Player o)` Compare the stack size of one player to another.
`void` | `fold()` Set the player's fold flag to true
`abstract java.lang.String` | `getAction()` GetAction is the method that all the inherited classes of the bot must implement.
`int` | `getBuyIn()` Get the amount the player bought in for
`java.lang.String` | `getCardString()` Get a string representation of thier best 5 card hand
`int` | `getCurrentBet()` Get the player's current betsize
`int` | `getHandRank()` Get the hand rank of the player's current hand
`java.lang.String` | `getHandString()` Get the @String representation of the player's cards.
`java.lang.String` | `getName()` Get the name of the player
`int` | `getPosition()` Get the players position relative to the button
`int` | `getScore()` Get the current score of the player
`int` | `getSeat()` Get the player's seat
`int` | `getStack()` Get the current stack size of the player
`int` | `getTotalCommitedToPot()` Get the total amount the player has committed to the pot
`private void` | `initializePlayer()` Set up all the defaults for the player, such as the acted and folded flags to false, the bets and scores to 0 and set the stack to the buyin value
`void` | `initTimeout(int timeout)` Set timeout, used for socket players
`boolean` | `isAAAIPlayer()` Check to see if this player is a AAAIPlayer
`boolean` | `isActed()` Check whether or not the player has acted in this round
`boolean` | `isAllIn()` Check to see if the player is all in.
`boolean` | `isFolded()` Check to see if the player has folded
`boolean` | `isGuiPlayer()` Check to see if the player is a GUIPlayer.
`boolean` | `isSocketPlayer()` Check to see if this player is a SocketPlayer
`void` | `payout(int pay)` Payout the player.
`int` | `postBlind(int blindSize)` A special type of bet where the player is considered not to have acted for the round
`void` | `resetHand()` Reset all of the per/hand values for the player, such as the acted and folded flags, the current bet, and the amount the player has commited to the pot so far
`void` | `resetPlayer(boolean doylesGame)` Reset the Player.
`void` | `resetRound()` Reset the per/round attributes such as the acted flag and currentBet for the player.
`void` | `resetStack()` Set the Player's stack back to the starting size.
`void` | `setBuyIn(int buyIn)` Set the buying amount for the player
`void` | `setCardString(java.lang.String cardString)` Set a string representing the players best 5 card poker hand
`void` | `setHandRank(int handRank)` Set the hand rank for the player
`void` | `setHandString(java.lang.String handString)` Set the string value of the player's current hand.
`void` | `setName(java.lang.String name)` Set the player's name
`void` | `setPosition(int position)` Set the players position relative to the button
`void` | `setScore(int score)` Set the current score for the player
`void` | `setSeat(int seat)` Set the player's seat
`void` | `setStack(int stack)` Set the current stack size for the player
`abstract void` | `shutdown()` All players must implement a shutdown routine
`void` | `subtractTotalCommitedToPot(int amount)` Subtract the amount from the Player's totalCommitedToPot value
`java.lang.String` | `toShortString()` A compact string representation of a Player object (name:stack:score:seat)
`java.lang.String` | `toString()` A string representation of a Player object
`abstract void` | `update(java.lang.String gamestate)` update is called by dealer to transmit the current gamestate in String representation to the player.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### name

    private java.lang.String name

### handString

    private java.lang.String handString

### cardString

    private java.lang.String cardString

### stack

    private int stack

### buyIn

    private int buyIn

### currentBet

    private int currentBet

### score

    private int score

### totalCommitedToPot

    private int totalCommitedToPot

### seat

    private int seat

### handRank

    private int handRank

### position

    private int position

### acted

    private boolean acted

### folded

    private boolean folded

Constructor Detail

### Player

    public Player()

  Default Player constructor

### Player

    public Player(java.lang.String name,
                  int buyIn)

  A constructor for a Player object that only takes a name, buyIn

  Parameters:
    `name` - A String representing the name
    `buyIn` - An int representing the buyin value for the player

Method Detail

### getBuyIn

    public int getBuyIn()

  Get the amount the player bought in for

  Returns:
    an int representing the buyin amount

### setBuyIn

    public void setBuyIn(int buyIn)

  Set the buying amount for the player

  Parameters:
    `buyIn` - an int representing the amount the player bought in for

### getScore

    public int getScore()

  Get the current score of the player

  Returns:
    an int representing the player's score

### setScore

    public void setScore(int score)

  Set the current score for the player

  Parameters:
    `score` - an int representing the player's score

### addToScore

    public void addToScore(int score)

  Add a value to the player's score

  Parameters:
    `score` - an int representing the amount to increment the score by

### isActed

    public boolean isActed()

  Check whether or not the player has acted in this round

  Returns:
    True if the player has acted, False otherwise

### isFolded

    public boolean isFolded()

  Check to see if the player has folded

  Returns:
    True if the player has folded, False otherwise

### isGuiPlayer

    public boolean isGuiPlayer()

  Check to see if the player is a GUIPlayer.

  Returns:
    False for all players other than those that override this method

### isSocketPlayer

    public boolean isSocketPlayer()

  Check to see if this player is a SocketPlayer

  Returns:
    False for all players other than those who override this method

### isAAAIPlayer

    public boolean isAAAIPlayer()

  Check to see if this player is a AAAIPlayer

  Returns:
    False for all players other than those who override this method

### getCurrentBet

    public int getCurrentBet()

  Get the player's current betsize

  Returns:
    an int representing the betsize of the player

### getTotalCommitedToPot

    public int getTotalCommitedToPot()

  Get the total amount the player has committed to the pot

  Returns:
    an int representing the amount the player has committed to the pot

### getName

    public java.lang.String getName()

  Get the name of the player

  Returns:
    a @String representing the player's name

### setName

    public void setName(java.lang.String name)

  Set the player's name

  Parameters:
    `name` - a @String representing the player's name

### getStack

    public int getStack()

  Get the current stack size of the player

  Returns:
    an int representing the current stack size

### setStack

    public void setStack(int stack)

  Set the current stack size for the player

  Parameters:
    `stack` - an int representing the stack size to set

### getSeat

    public int getSeat()

  Get the player's seat

  Returns:
    an int representing which seat the player is currently sitting in

### setSeat

    public void setSeat(int seat)

  Set the player's seat

  Parameters:
    `seat` - an int representing which seat the player is to be assigned

### getHandRank

    public int getHandRank()

  Get the hand rank of the player's current hand

  Returns:
    an int representing the hand rank of the player. Note: this is not calculated by the player, but rather assigned on showdown by the @Dealer

### setHandRank

    public void setHandRank(int handRank)

  Set the hand rank for the player

  Parameters:
    `handRank` - an int representing the hand rank as calculated by the @Dealer

### getHandString

    public java.lang.String getHandString()

  Get the @String representation of the player's cards. This is calculated by the @HandEvaluator from teh @Dealer class

  Returns:
    a @String representing the best 5-Card hand the player has made

### setHandString

    public void setHandString(java.lang.String handString)

  Set the string value of the player's current hand. This is used for showdowns on the gui

  Parameters:
    `handString` - The string that represents the players hand

### getCardString

    public java.lang.String getCardString()

  Get a string representation of thier best 5 card hand

  Returns:
    a String representation of the player's best 5 card hand

### setCardString

    public void setCardString(java.lang.String cardString)

  Set a string representing the players best 5 card poker hand

  Parameters:
    `cardString` - A string that represents the players 5 best cards

### getPosition

    public int getPosition()

  Get the players position relative to the button

  Returns:
    The player's position, 0 being the

### setPosition

    public void setPosition(int position)

  Set the players position relative to the button

  Parameters:
    `position` - The position the player is in. 0 is the button.

### shutdown

    public abstract void shutdown()

  All players must implement a shutdown routine

### subtractTotalCommitedToPot

    public void subtractTotalCommitedToPot(int amount)

  Subtract the amount from the Player's totalCommitedToPot value

  Parameters:
    `amount` - Amount to subtract

### initializePlayer

    private void initializePlayer()

  Set up all the defaults for the player, such as the acted and folded flags to false, the bets and scores to 0 and set the stack to the buyin value

### bet

    public int bet(int betSize)

  Make a bet of the passed in size. This will decrement the Player's stack, increase thier current bet and total commited to the pot, as well as set thier acted flag for the round to true.

  Parameters:
    `betSize` -
  Returns:
    The size of the bet that is made

### postBlind

    public int postBlind(int blindSize)

  A special type of bet where the player is considered not to have acted for the round

  Parameters:
    `blindSize` - The size of bet that the player makes
  Returns:
    The players current bet

### fold

    public void fold()

  Set the player's fold flag to true

### getAction

    public abstract java.lang.String getAction()

  GetAction is the method that all the inherited classes of the bot must implement. This is called by the dealer to get the bot's actions

  Returns:
    one of {f,c,r,rX} where X is a raise amount

### update

    public abstract void update(java.lang.String gamestate)

  update is called by dealer to transmit the current gamestate in String representation to the player. This tells the player what the current gamestate is.

  Parameters:
    `gamestate` - The AAAI competition formated string representation of the gamestate

### call

    public int call(int currentBet)

  Have the player call the current bet This will take the player's current bet and figure out how much more the player has to bet to call, make that bet then return the amount it cost to make the bet since there will be some cases where a call will be more that the player's stack and the player will then be all in for less than the amount needed to call

  Parameters:
    `currentBet` - The size of the bet that the player needs to call
  Returns:
    The amount that the player bet to call the current bet passed in

### isAllIn

    public boolean isAllIn()

  Check to see if the player is all in. This is whether or not they have any chips left in thier stack

  Returns:
    True if stack <= 0

### payout

    public void payout(int pay)

  Payout the player. That is, increase thier stack by the value passed in.

  Parameters:
    `pay` - The amount to increase the player's stack by

### resetRound

    public void resetRound()

  Reset the per/round attributes such as the acted flag and currentBet for the player.

### resetHand

    public void resetHand()

  Reset all of the per/hand values for the player, such as the acted and folded flags, the current bet, and the amount the player has commited to the pot so far

### resetStack

    public void resetStack()

  Set the Player's stack back to the starting size. Used for Doyle's game

### resetPlayer

    public void resetPlayer(boolean doylesGame)

  Reset the Player. This will reset the player's current stack to the starting value, all of the per/hand attribures and the score to 0

  Parameters:
    `doylesGame` -

### toString

    public java.lang.String toString()

  A string representation of a Player object

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    A String representation of this player.

### toShortString

    public java.lang.String toShortString()

  A compact string representation of a Player object (name:stack:score:seat)

  Returns:
    A compact String representation of this player.

### compareTo

    public int compareTo(Player o)

  Compare the stack size of one player to another. Used to sort the players by stacksize in the game

  Specified by:
    `compareTo` in interface `java.lang.Comparable<Player>`
  Parameters:
    `o` - The player to compare this player to.
  Returns:
    0 if the stacks are equal, Positive if the other player has a stack larger than this player, Negative if this player has a stack larger than the player being compared to.

### initTimeout

    public void initTimeout(int timeout)

  Set timeout, used for socket players

  Parameters:
    `timeout` - Timeout for the player's actions

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD