org.jogre.common
Class PlayerList

java.lang.Object
  |
  +--org.jogre.common.PlayerList
All Implemented Interfaces:
ITransmittable

public class PlayerList
extends Object
implements ITransmittable

This class contains a list of Player object.s

Version:
Alpha 0.1
Author:
Bob Marks

Field Summary
protected static int NUM_OF_HEADER_TOKENS
          Number of header tokens.
protected static int NUM_OF_TOKENS
          Number of tokens which a PlayerList flattens to.
static String PLAYER_LIST
          Header token String.
 
Constructor Summary
PlayerList()
          Default constructor
PlayerList(String inString)
           
 
Method Summary
 void addPlayer(String playerName)
          Add a player to the table.
 boolean containsUser(String player)
          Return true if the list contains the player.
 String flatten()
          Flatten the String so that it can be transmitted.
 Player getCurrentPlayer()
          Current player as an object
 String getCurrentPlayerName()
          Return the currrent player if a turned based game.
 String getOwner()
          Return the owner of this table.
 Player getPlayer(int seatNum)
          Return a player from a seat number.
 Player getPlayer(String playerName)
          Return a player.
 Vector getPlayers()
          Return a vector of players which arn't sorted.
 Vector getPlayersSortedByName()
          Return a vector of all the players in this list which are sorted by name (used for visual lists etc).
 Vector getPlayersSortedBySeat()
          Return a vector of all the players in this list which are sorted by seat number (used for the game logic).
 Vector getPlayersSortedBySeat(int state)
          Return a vector of all the players in this list which are currently actually playing a game.
 int getPlayerStateCount(int state)
          Returns the number of players in a particular state.
 boolean isSeatFree(int seatNum)
          Return true if a seat at a table is free.
 int length()
          Number of tokens.
 void nextPlayer()
          Makes the current player equal to the next player.
 void removePlayer(String player)
          Remove a player.
 void resetCurrentPlayer()
          Sets the current player to the person with the smallest seat number.
 int size()
          Return the number of users playing at a particular table.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLAYER_LIST

public static final String PLAYER_LIST
Header token String.

NUM_OF_HEADER_TOKENS

protected static final int NUM_OF_HEADER_TOKENS
Number of header tokens.

NUM_OF_TOKENS

protected static final int NUM_OF_TOKENS
Number of tokens which a PlayerList flattens to.
Constructor Detail

PlayerList

public PlayerList()
Default constructor

PlayerList

public PlayerList(String inString)
           throws TransmissionException
Parameters:
inString -  
Throws:
TransmissionException -  
NumberFormatException -  
Method Detail

addPlayer

public void addPlayer(String playerName)
Add a player to the table.
Parameters:
playerName - Name of the player to add to table.

removePlayer

public void removePlayer(String player)
Remove a player.
Parameters:
player - Name of player to remove.

size

public int size()
Return the number of users playing at a particular table.
Returns:
Number of players.

containsUser

public boolean containsUser(String player)
Return true if the list contains the player.
Parameters:
player -  
Returns:
 

getOwner

public String getOwner()
Return the owner of this table.
Returns:
 

getPlayer

public Player getPlayer(String playerName)
Return a player.
Parameters:
playerName -  
Returns:
 

getPlayer

public Player getPlayer(int seatNum)
Return a player from a seat number. Returns null if a player isn't found.
Parameters:
seatNum - Seat number of a user.
Returns:
 

getPlayers

public Vector getPlayers()
Return a vector of players which arn't sorted.
Returns:
 

nextPlayer

public void nextPlayer()
Makes the current player equal to the next player.

resetCurrentPlayer

public void resetCurrentPlayer()
Sets the current player to the person with the smallest seat number.

getCurrentPlayerName

public String getCurrentPlayerName()
Return the currrent player if a turned based game.
Returns:
 

getCurrentPlayer

public Player getCurrentPlayer()
Current player as an object
Returns:
 

getPlayersSortedByName

public Vector getPlayersSortedByName()
Return a vector of all the players in this list which are sorted by name (used for visual lists etc).
Returns:
 

getPlayersSortedBySeat

public Vector getPlayersSortedBySeat(int state)
Return a vector of all the players in this list which are currently actually playing a game.
Parameters:
state - State of the player e.g. game in state
Returns:
 

getPlayersSortedBySeat

public Vector getPlayersSortedBySeat()
Return a vector of all the players in this list which are sorted by seat number (used for the game logic).
Returns:
 

getPlayerStateCount

public int getPlayerStateCount(int state)
Returns the number of players in a particular state.
Parameters:
state -  
Returns:
Count of the specified state.

isSeatFree

public boolean isSeatFree(int seatNum)
Return true if a seat at a table is free.
Parameters:
seatNum - Seat number to check.
Returns:
If seat is free, return true.

length

public int length()
Number of tokens.
Returns:
 

flatten

public String flatten()
Flatten the String so that it can be transmitted.
Specified by:
flatten in interface ITransmittable
See Also:
ITransmittable.flatten()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()