de.kosi.model
Interface Table

All Superinterfaces:
java.rmi.Remote
All Known Implementing Classes:
TableImpl

public interface Table
extends java.rmi.Remote

This interface gives access to the methods of a table representation. That is the place where the Bridge games take place. At each table should only one game of Bridge take place simultaneously. Before the game takes place there can be one, two or three players be waiting at the table for the missing participants. If four players have arrived at the table, it must create a new Game instance to let the players play it.
Users can also be allowed to watch a table so the table must manage a list of players (e.g. using the de.kosi.model.game.Players class) and a list of watchers.
Every user can create a table where a game of Bridge can take place. The creator of the Table should become the owner of the table which is a special user who is allowed to invite other users to this table or kick other users from this table.
To let the players and possibly also the watchers talk to the others a Table should provide a chat channel.

ChangeLog:

 $Log: Table.java,v $
 Revision 1.7  2001/08/21 14:15:22  betacarotine
 the computer player should be startable from the table now, but is not
 automatically removed from memory...

 Revision 1.6  2001/08/21 11:23:45  betacarotine
 continued implementing the computer player integration

 Revision 1.5  2001/08/21 09:25:52  betacarotine
 started adding the possibility to start the computer player from the table

 Revision 1.4  2001/07/04 12:34:30  uid30828
 - Rubber score implemented
 - Inviting now working

 Revision 1.3  2001/07/04 12:17:12  uid51247
 now the rubber valuations are available to the clients

 Revision 1.2  2001/05/09 11:44:40  betacarotine
 The Table interface got a getDirection method that returns the
 direction of the calling user.

 Revision 1.1.1.1  2001/04/29 18:05:17  jiriki
 Imported sources from zola.

 Revision 1.11  2001/03/19 21:50:49  wombat
 - Worked on admin client.
 - improved shutdown sequence
 - removed bugs in login/logout sequence

 Revision 1.10  2001/03/01 20:31:32  wombat
 Worked on table implementation / updated documentation

 Revision 1.9  2001/03/01 14:43:00  wombat
 Worked on table implementation.

 Revision 1.8  2001/03/01 11:37:25  wombat
 worked on table implementation.

 Revision 1.7  2001/02/27 14:43:13  wombat
 Updated documentation.

 Revision 1.6  2001/02/26 11:21:45  wombat
 Worked on table.

 Revision 1.5  2001/02/11 17:49:29  login
 documented de.kosi.model.Table

 Revision 1.4  2001/02/11 17:21:33  login
 started documenting


 

Version:
$Revision: 1.7 $ ($Date: 2001/08/21 14:15:22 $)
Author:
Timo, Niklas, Ole

Method Summary
 java.util.List getAvailableComputerPlayers()
          Returns a list of available computer players.
 ChatChannel getChatChannel()
          Returns the chat channel of this table where the players can communicate.
 int getDirection()
          Returns the direction of the calling player.
 Game getGame()
          Returns the game of Bridge that takes place at this table or null if there is currently no game played.
 java.lang.String getOwner()
          Returns the name of the table's owner.
 java.lang.String[] getPlayerNames()
          Returns an array of Strings representing the players.
 Rubber getRubber()
          Returns the currently played rubber or the just finished rubber.
 java.lang.String[] getWatcherNames()
          Returns an array containing the names of all watchers at this table.
 void invitePlayer(java.lang.String name, int direction)
          Invites a player to this table.
 void joinTable(TableListener tableListener, int direction)
          A client can call this method to join this table.
 void kickPlayer(java.lang.String name)
          Kicks a player from the table.
 void leaveTable()
          This method should be called to leave the table.
 void startComputerPlayer(java.lang.String computerPlayer, int direction)
          Starts a computer player that is seated at the given direction.
 void watchTable(TableListener tableListener)
          Call this method to watch the table.
 

Method Detail

getChatChannel

public ChatChannel getChatChannel()
                           throws java.rmi.RemoteException
Returns the chat channel of this table where the players can communicate.
Returns:
A chat channel.
Throws:
java.rmi.RemoteException - If the remote call of this method fails.

getRubber

public Rubber getRubber()
                 throws java.rmi.RemoteException
Returns the currently played rubber or the just finished rubber.
Returns:
A rubber.

joinTable

public void joinTable(TableListener tableListener,
                      int direction)
               throws java.rmi.RemoteException,
                      TableException,
                      InvalidSessionException,
                      UserAlreadyPlayingException,
                      TableSeatTakenException
A client can call this method to join this table.
Parameters:
tableListener - A listener that will be notified of events at the table.
direction - The direction of the player. Its value must be Player.NORTH, Player.EAST, Player.SOUTH or Player.WEST.
Throws:
java.rmi.RemoteException - If the remote call fails.
TableException - If the table cannot be joined.
InvalidSessionException - when not called from within a valid session context.
UserAlreadyPlayingException - If the user calling this method is already playing.
TableSeatTakenException - If the seat in direction is already taken.

watchTable

public void watchTable(TableListener tableListener)
                throws java.rmi.RemoteException,
                       InvalidSessionException
Call this method to watch the table.
Parameters:
tableListener - A listener that will be notified of events regarding this table.
Throws:
java.rmi.RemoteException - If RMI runs into trouble.
InvalidSessionException - when not called from within a valid session context.

leaveTable

public void leaveTable()
                throws java.rmi.RemoteException,
                       InvalidSessionException
This method should be called to leave the table.
Throws:
java.rmi.RemoteException - If the remote call of this method fails.
InvalidSessionException - when not called from within a valid session context.

getPlayerNames

public java.lang.String[] getPlayerNames()
                                  throws java.rmi.RemoteException
Returns an array of Strings representing the players. At index 0 will be the player seated at north, index 1 for player at east, 2 for south and 3 for west. For easy access use the constants Player.NORTH, Player.EAST, Player.SOUTH respectively Player.WEST. Always an array instance of length 4 will be returned, never null - but if there are only three or less players at this table there will be a null value in the array stored at the index where no player is seated.
Returns:
An array of Strings.
Throws:
java.rmi.RemoteException - If the remote call fails.

getWatcherNames

public java.lang.String[] getWatcherNames()
                                   throws java.rmi.RemoteException
Returns an array containing the names of all watchers at this table. If there are no watchers, null will be returned.
Returns:
An array of watcher names or null if there are no watchers.
Throws:
java.rmi.RemoteException - If the remote call fails.

getOwner

public java.lang.String getOwner()
                          throws java.rmi.RemoteException
Returns the name of the table's owner.
Returns:
The name of the table's owner.
Throws:
java.rmi.RemoteException - If the remote call fails.

getGame

public Game getGame()
             throws java.rmi.RemoteException
Returns the game of Bridge that takes place at this table or null if there is currently no game played.
Returns:
A game instance or null.
Throws:
java.rmi.RemoteException - If RMI runs into trouble.

kickPlayer

public void kickPlayer(java.lang.String name)
                throws java.rmi.RemoteException,
                       KosiAccessException,
                       InvalidSessionException
Kicks a player from the table. Only the owner of this table should be allowed to call this method.
Parameters:
name - The name of the player that is to be kicked.
Throws:
java.rmi.RemoteException - If the remote call fails.
KosiAccessException - When not called by the owner of the table.
InvalidSessionException - When not called from within a valid session context. owner of the table.

getAvailableComputerPlayers

public java.util.List getAvailableComputerPlayers()
                                           throws java.rmi.RemoteException
Returns a list of available computer players.
Returns:
List of available computer player class names.
Throws:
java.rmi.RemoteException - Guess...

startComputerPlayer

public void startComputerPlayer(java.lang.String computerPlayer,
                                int direction)
                         throws java.rmi.RemoteException,
                                KosiAccessException,
                                InvalidSessionException,
                                ComputerPlayerException
Starts a computer player that is seated at the given direction.
Parameters:
computerPlayer - Class name of the desired computer player.
direction - The direction the computer player is seated at.
Throws:
java.rmi.RemoteException - If the remote call failed.
KosiAccessException - If not called by the table owner.
InvalidSessionException - If called from an invalid session context.

invitePlayer

public void invitePlayer(java.lang.String name,
                         int direction)
                  throws java.rmi.RemoteException,
                         KosiAccessException,
                         InvalidSessionException,
                         UserUnavailableException
Invites a player to this table. Only the owner should be allowed to do this.
Parameters:
name - The name of the user that is to be invited.
Throws:
java.rmi.RemoteException - If the remote call fails.
KosiAccessException - If the caller of this method is not the owner of the table.
InvalidSessionException - When not called from within a valid session context.
UserUnavailableException - If the invited user is not available.

getDirection

public int getDirection()
                 throws KosiAccessException,
                        InvalidSessionException,
                        java.rmi.RemoteException
Returns the direction of the calling player. This method can be used by a player to find out the direction he is playing at.
Returns:
one of the Player constante (NORTH, SOUTH, EAST, WEST).
Throws:
KosiAccessException - if the player is not currently seated at this game
InvalidSessionException - if not called from a valid session context. and therefor has no direction assigned.
java.rmi.RemoteException - If the RMI call fails.