org.jogre.common
Class Table

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

public class Table
extends Object
implements ITransmittable

Server side data object which holds information on various tables and their current users etc.

Version:
Alpha 0.1
Author:
Bob Marks

Field Summary
static int NUM_OF_HEADER_TOKENS
          Number of tokens which a Player flattens to.
static String TABLE
          Header token String.
 
Constructor Summary
Table(int tableNumber, String username, boolean isPublic)
          Create a table and 1 user (owner)
Table(String inString)
          Create Table object from a String.
 
Method Summary
 void addPlayer(String playerName)
          Add a user to the table i.e.
 boolean containsUser(String user)
          Returns true if a specified user is at a table.
 String flatten()
          Flatten the table object.
 void gameOver()
          Game over.
 JogreModel getModel()
          Retrieve the model from the server (if its being used).
 String getModelStr()
          Retrieve the model as a String from the server (if its being used).
 String getOwner()
          Get the owner of this table.
 PlayerList getPlayerList()
           
 int getTableNum()
          Get the number of this table.
 boolean isGamePlaying()
          Return true if a game is in progress.
 boolean isModelStateAttached()
          Return if the model state is attached or not.
 boolean isPublic()
          Returns true if this is a public table.
 int length()
          Return the length (number of tokens in the flatten() methodof this particular
 String nextPlayer()
          Sets the next player username.
 void removePlayer(String player)
          Remove a player from the list.
 void setModel(JogreModel model)
          Set the game data.
 void setModelStateAttached(boolean value)
          Set true if the model state is to be attached or not.
 String toString()
          Return the String version of this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLE

public static final String TABLE
Header token String.

NUM_OF_HEADER_TOKENS

public static final int NUM_OF_HEADER_TOKENS
Number of tokens which a Player flattens to.
Constructor Detail

Table

public Table(int tableNumber,
             String username,
             boolean isPublic)
Create a table and 1 user (owner)
Parameters:
tableNumber - The table number of the new table.
username - Username (owner).
isPublic - boolean to show if a table is public or private.

Table

public Table(String inString)
      throws TransmissionException,
             NumberFormatException
Create Table object from a String.
Parameters:
inString -  
Throws:
TransmissionException - Thrown if there is a problem in transmission.
NumberFormatException - Problem parsing an int.
Method Detail

addPlayer

public void addPlayer(String playerName)
Add a user to the table i.e. a user joins a table
Parameters:
playerName - Username of the player.

removePlayer

public void removePlayer(String player)
Remove a player from the list.
Parameters:
player - Username of the player.

gameOver

public void gameOver()
Game over.

getTableNum

public int getTableNum()
Get the number of this table.
Returns:
table number as an integer.

getPlayerList

public PlayerList getPlayerList()
Returns:
 

containsUser

public boolean containsUser(String user)
Returns true if a specified user is at a table.
Parameters:
user -  
Returns:
 

getOwner

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

isPublic

public boolean isPublic()
Returns true if this is a public table.
Returns:
 

getModel

public JogreModel getModel()
Retrieve the model from the server (if its being used).
Returns:
 

getModelStr

public String getModelStr()
Retrieve the model as a String from the server (if its being used).
Returns:
 

setModel

public void setModel(JogreModel model)
Set the game data.
Parameters:
model -  

nextPlayer

public String nextPlayer()
Sets the next player username.
Returns:
Username of the next player.

setModelStateAttached

public void setModelStateAttached(boolean value)
Set true if the model state is to be attached or not.
Parameters:
value -  

isModelStateAttached

public boolean isModelStateAttached()
Return if the model state is attached or not.
Returns:
 

length

public int length()
Return the length (number of tokens in the flatten() methodof this particular
Returns:
 

flatten

public String flatten()
Flatten the table object. Also include the model of the current game if the modelStateIsAttached variable is set.
Specified by:
flatten in interface ITransmittable
See Also:
ITransmittable.flatten()

toString

public String toString()
Return the String version of this table.
Overrides:
toString in class Object
See Also:
Object.toString()

isGamePlaying

public boolean isGamePlaying()
Return true if a game is in progress. This method loops through the various Player object in the PlayerList to see if any of them are in the PlayerStateGameStarted state.
Returns: