de.kosi.model
Class TableImpl

java.lang.Object
  |
  +--de.kosi.model.TableImpl
All Implemented Interfaces:
GameContainer, java.rmi.Remote, Table, UserListener

public class TableImpl
extends java.lang.Object
implements Table, UserListener, GameContainer

This class is the implementation of a KoSI Table.

ChangeLog:

 $Log: TableImpl.java,v $
 Revision 1.17  2001/08/30 10:44:38  jiriki
 Finished implementation of claim

 Revision 1.16  2001/08/23 11:45:36  betacarotine
 worked on computer player integration

 Revision 1.15  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.14  2001/08/21 11:23:45  betacarotine
 continued implementing the computer player integration

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

 Revision 1.12  2001/07/20 14:37:08  jiriki
 Fixed Bug 440605

 Revision 1.11  2001/07/13 14:43:35  betacarotine
 updated documentation

 Revision 1.10  2001/07/13 14:07:34  betacarotine
 updated documentation

 Revision 1.9  2001/07/13 10:49:06  jiriki
 Started fix for Bugs 440155 and 440333.

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

 Revision 1.7  2001/07/04 12:20:56  uid51247
 removed a spelling bug in the comments

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

 Revision 1.5  2001/06/22 13:24:32  jiriki
 Implemented kicking

 Revision 1.4  2001/05/30 22:22:13  jiriki
 - Added new files to build file.
 - Worked on GameView.

 Revision 1.3  2001/05/09 19:59:18  jiriki
 Removed Bug 422755.

 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.24  2001/04/17 19:30:08  wombat
 Updated Documentation

 Revision 1.23  2001/04/11 18:08:14  wombat
 Client can now write into the table chat.

 Revision 1.22  2001/04/11 16:54:04  wombat
 Removed some bugs when joining table and immidiatly leaving again.

 Revision 1.21  2001/04/11 12:34:32  wombat
 jar files restructured.

 Revision 1.20  2001/04/09 13:03:10  wombat
 Removed timeout from threadpool (did not work)

 Revision 1.19  2001/03/29 09:49:52  wombat
 Made createNewGame synchronized.

 Revision 1.18  2001/03/23 10:48:52  wombat
 - Table now restarts game
 - began GuestUser implementation

 Revision 1.17  2001/03/21 22:34:40  wombat
 Worked on StressClient, removed bugs in GameImpl/Bidding, improved logging

 Revision 1.16  2001/03/21 13:26:36  wombat
 - Removed bugs in Table
 - began implementation of stree client
 - updated documentation

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

 Revision 1.14  2001/03/05 20:55:22  login
 - Game (und zugehoerige Klassen) soweit fertig
 - package de.kosi.model.tournament angelegt
 - Pair angelegt
 - Round angelegt
 - Movement-Interface angelegt
 - KosiMovement fertig!!! :-)
 - KosiMovementTest um das KosiMovement zu testen
       (kann mit KOSI/kosimovementtest  aufgerufen werden)
 - Tournament und TournamentImpl in das package de.kosi.model.tournament
       verschoben
 - buildfile fuer die neuen klassen angepasst

 Revision 1.13  2001/03/02 09:43:14  wombat
 Worked on gameimpl

 Revision 1.12  2001/03/01 21:28:14  wombat
 Updated TestClient
 Resolved some bugs

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

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

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

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

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

 Revision 1.6  2001/02/21 11:38:46  wombat
 Worked on GameImpl and Board

 Revision 1.5  2001/02/20 11:32:17  wombat
 Started GameImpl implementation.

 Revision 1.4  2001/02/07 16:54:04  wombat
 Updated Documentation

 

Version:
$Revision: 1.17 $ ($Date: 2001/08/30 10:44:38 $)

Field Summary
static java.lang.String[] AVAILABLE_COMPUTER_PLAYERS
           
static java.util.Hashtable AVAILABLE_COMPUTER_PLAYERS_MAP
           
 
Constructor Summary
TableImpl(DistributedListImpl tablelist, UserImpl owner, TableListener ownerTableListener, int ownerDirection, boolean publicTable)
          Creates a new table.
 
Method Summary
 void appealToJudge(java.lang.String reason)
          Appeal to a judge.
 void destroyed(UserImpl user)
          Called when a UserImpl Object is about to be destroyed.
 void gameFinished(Result result)
          Called by the game when it has just been finished.
 java.util.List getAvailableComputerPlayers()
          Returns a list of available computer players.
 ChatChannel getChatChannel()
          Returns the ChatChannel of this table.
 int getDirection()
          Returns the direction of the calling player.
 Game getGame()
          Returns the Game currently being played.
 java.lang.String getOwner()
          Returns the name of the user currently owning this table.
 UserImpl getOwningUser()
           
 java.lang.String[] getPlayerNames()
          Returns the Playernames.
 Rubber getRubber()
          Returns the currently played rubber or the just finished rubber.
 java.lang.String[] getWatcherNames()
          Returns the users watching this table.
 void invitePlayer(java.lang.String name, int direction)
          Invite a Player to the Table.
 void joinTable(TableListener tableListener, int direction)
          This method is called to join the table.
 void kickPlayer(java.lang.String name)
          Remove a Player from the Table.
 void leaveTable()
          This method is called to leave the table.
 void onlineChange(UserImpl user, boolean isOnline)
          This method is called when the online status of the user changes.
 void startComputerPlayer(java.lang.String computerPlayer, int direction)
          Starts a computer player that is seated at the given direction.
 void watchTable(TableListener tableListener)
          This method is called to watch the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AVAILABLE_COMPUTER_PLAYERS

public static final java.lang.String[] AVAILABLE_COMPUTER_PLAYERS

AVAILABLE_COMPUTER_PLAYERS_MAP

public static final java.util.Hashtable AVAILABLE_COMPUTER_PLAYERS_MAP
Constructor Detail

TableImpl

public TableImpl(DistributedListImpl tablelist,
                 UserImpl owner,
                 TableListener ownerTableListener,
                 int ownerDirection,
                 boolean publicTable)
          throws java.rmi.RemoteException,
                 InvalidSessionException,
                 TableException,
                 UserAlreadyPlayingException
Creates a new table.
Parameters:
tablelist - List of tables. This table has to add itself to this list, after it has been exported for RMI.
owner - Initial owner of this table.
ownerTableListener - TableListener of the owner.
ownerDirection - Position at the Table. This is one of the Player constants (NORTH, SOUTH, EAST, WEST)
publicTable - Wether this table is public.
Throws:
java.rmi.RemoteException - if the table could not be exported.
InvalidSessionException - when not called from within a valid session context.
UserAlreadyPlayingException - If the owner is already playing.
TableException - if an error occurs while creating the table.
Method Detail

getRubber

public Rubber getRubber()
Returns the currently played rubber or the just finished rubber.
Specified by:
getRubber in interface Table
Returns:
The currently played rubber or the just finished rubber.

getChatChannel

public ChatChannel getChatChannel()
Returns the ChatChannel of this table.
Specified by:
getChatChannel in interface Table
Returns:
ChatChannel.

joinTable

public void joinTable(TableListener tableListener,
                      int direction)
               throws TableException,
                      InvalidSessionException,
                      TableSeatTakenException,
                      UserAlreadyPlayingException,
                      java.rmi.RemoteException
This method is called to join the table.
Specified by:
joinTable in interface Table
Parameters:
tableListener - listener that is called when the state of the table changes.
direction - Direction the joining user wants to sit in.This is one of the Player constants (NORTH, SOUTH, EAST, WEST).
Throws:
TableException - if the player cannot jooin the table. Further explanation is contained in the Exception.
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.
java.rmi.RemoteException - If exporting the GameImpl was not possible.

watchTable

public void watchTable(TableListener tableListener)
                throws InvalidSessionException
This method is called to watch the table.
Specified by:
watchTable in interface Table
Parameters:
tableListener - listener that is called when the state of the table changes.
Throws:
InvalidSessionException - when not called from within a valid session context.

leaveTable

public void leaveTable()
                throws InvalidSessionException
This method is called to leave the table.
Specified by:
leaveTable in interface Table
Throws:
InvalidSessionException - when not called from within a valid session context.

getPlayerNames

public java.lang.String[] getPlayerNames()
Returns the Playernames.
Specified by:
getPlayerNames in interface Table
Returns:
Array containing the names of the players. The array has always four entries, but may contain null entries, if there is currently no player playing.

getWatcherNames

public java.lang.String[] getWatcherNames()
Returns the users watching this table.
Specified by:
getWatcherNames in interface Table
Returns:
array of usernames.

getOwner

public java.lang.String getOwner()
Returns the name of the user currently owning this table. Not, that this can be null, if the table is empty, and not unexported yet.
Specified by:
getOwner in interface Table
Returns:
name of the owner.

getOwningUser

public UserImpl getOwningUser()

getGame

public Game getGame()
Returns the Game currently being played.
Specified by:
getGame in interface Table
Returns:
A Game or null if there is no active Game.

kickPlayer

public void kickPlayer(java.lang.String name)
                throws KosiAccessException,
                       InvalidSessionException
Remove a Player from the Table. This method may only be called by the owner of the table.
Specified by:
kickPlayer in interface Table
Parameters:
name - Name of the player to remove.
Throws:
KosiAccessException - if not called by the owner of the table.
InvalidSessionException - when not called from within a valid session context.

invitePlayer

public void invitePlayer(java.lang.String name,
                         int direction)
                  throws KosiAccessException,
                         InvalidSessionException,
                         UserUnavailableException
Invite a Player to the Table. This method may only be called by the owner of the table.
Specified by:
invitePlayer in interface Table
Parameters:
name - Name of the player to remove.
Throws:
KosiAccessException - If not called by the owner of the table.
InvalidSessionException - If not called from within a valid session context.
UserUnavailableException - If the invited user is not available.

getAvailableComputerPlayers

public java.util.List getAvailableComputerPlayers()
Returns a list of available computer players.
Specified by:
getAvailableComputerPlayers in interface Table
Returns:
List of available computer player names.

startComputerPlayer

public void startComputerPlayer(java.lang.String computerPlayer,
                                int direction)
                         throws KosiAccessException,
                                InvalidSessionException,
                                ComputerPlayerException
Starts a computer player that is seated at the given direction. If the table seat is taken just before the computer player takes it no error or warning is produced because the computer player is actually only invited to the table.
Specified by:
startComputerPlayer in interface Table
Parameters:
computerPlayer - The name of the computer player.
direction - The direction the computer player is seated at.
Throws:
KosiAccessException - If not called by the table owner.
InvalidSessionException - If called from an invalid session context.
java.lang.ClassNotFoundException - If the given computer player class name does not represent a valid class.

getDirection

public int getDirection()
                 throws KosiAccessException,
                        InvalidSessionException
Returns the direction of the calling player. This method can be used by a player to find out the direction he is playing at.
Specified by:
getDirection in interface Table
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.

onlineChange

public void onlineChange(UserImpl user,
                         boolean isOnline)
This method is called when the online status of the user changes.
Specified by:
onlineChange in interface UserListener
Parameters:
user - user whose state changed.
isOnline - wether the user is online.

destroyed

public void destroyed(UserImpl user)
Called when a UserImpl Object is about to be destroyed.
Specified by:
destroyed in interface UserListener
Parameters:
user - UserImpl object to be destroyed.

gameFinished

public void gameFinished(Result result)
Description copied from interface: GameContainer
Called by the game when it has just been finished.
Specified by:
gameFinished in interface GameContainer
Following copied from interface: de.kosi.model.game.GameContainer
Parameters:
result - The result of the game.

appealToJudge

public void appealToJudge(java.lang.String reason)
Appeal to a judge. This method gives players the possibility to request a judgement for a game. A reason for this has to be stated.
Specified by:
appealToJudge in interface GameContainer
Parameters:
reason - Reason for calling a judge.