de.kosi.model.game
Interface Game

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

public interface Game
extends java.rmi.Remote

This is the interface to a game of Bridge as it is seen by the Client. The interface does not contain methods, that are used internally. These can be found in the class GameImpl. If a method call fails with a RemoteException, it is unclear, wether the state of the Game changed. In this case the client should repeat the method call. The Game implementation is responsible for sorting out duplicate calls and throwing exceptions to inform the client on this.

ChangeLog:

 
 $Log: Game.java,v $
 Revision 1.6  2001/08/28 12:35:23  jiriki
 Started Implementation of claim

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

 Revision 1.4  2001/06/15 12:51:06  betacarotine
 Added the possibility to get the number of tricks that the declarer made
 while the game's state is PLAYING.

 Revision 1.3  2001/06/15 09:33:27  betacarotine
 Changed the Game-interface. Instead of
 	int getLatestLeader()   and
 	List getLatestTrick()
 we now have
 	Trick getLatestTrick()

 The internal representation and storage of the tricks is reimplemented too
 based on the new Trick-class.

 Revision 1.2  2001/05/23 13:28:27  betacarotine
 updated docs

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

 Revision 1.21  2001/04/17 19:30:08  wombat
 Updated Documentation

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

 Revision 1.19  2001/04/08 14:42:37  wombat
 Foyer chat entfernt.

 Revision 1.18  2001/04/08 14:30:44  wombat
 Anfang Implementierung der selbst-alertierung

 Revision 1.17  2001/03/29 21:01:04  wombat
 - Improved logging.
 - Removed bugs from StressClient

 Revision 1.16  2001/03/27 10:38:53  wombat
 Added getOpener method and modified StressClient to user it.
 There is a problem with the StressClient, when the listeners are
 not registered before events are sent. The GameImpl should the last
 event to the listener, after it registered.

 Revision 1.15  2001/03/22 16:40:46  wombat
 - Updated ant to 1.3
 - Removed bugs in GameImpl and StressClient

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

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

 Revision 1.12  2001/03/15 19:19:48  login
 Worked on GameImpl to make it possible that the declarer plays the dummy's cards
 and prohibit that the dummy does anything.

 Revision 1.11  2001/03/06 18:07:19  login
 documented

 Revision 1.10  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.9  2001/03/02 09:43:14  wombat
 Worked on gameimpl

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

 Revision 1.7  2001/02/26 15:21:37  wombat
 worked on GamImpl and Board

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

 Revision 1.5  2001/02/19 15:51:47  wombat
 - Latex Task geschrieben
 - Entwurfsdokumente in Webseite eingebunden
 - Game Entwurfsdokument und Source aktualisiert.

 Revision 1.4  2001/02/11 23:36:26  wombat
 Started implementation of Game.

 Revision 1.3  2001/02/09 19:26:32  login
 Doc-Update

 Revision 1.2  2001/02/06 15:37:44  login
 Updated docs


 

Version:
$Revision: 1.6 $ ($Date: 2001/08/28 12:35:23 $)
Author:
Timo, Niklas, Ole

Field Summary
static int BIDDING
          Value (returned by getStatus()) indicating that this game is in the state of bidding.
static int CLAIMING
          Value (returned by getStatus()) indicating that this game is in the state of claiming.
static int FINISHED
          Value (returned by getStatus()) indicating that this game has ended.
static int PLAYING
          Value (returned by getStatus())indicating that this game is in the state of playing.
 
Method Summary
 void addGameListener(GameListener listener)
          Add a GameListener to this Game.
 void answerClaim(boolean accept)
          Answer a claim.
 void appealToJudge(java.lang.String reason)
          Appeal to a judge.
 void bid(Bid bid, boolean alert)
          Bid a bid.
 void claim(int tricks)
          Claim the remaining tricks.
 int getActivePlayer()
          Returns the player (direction), that is currently due to make a move.
 Alert getAlert(int round, int player)
          Returns an Alert.
 java.util.List getBids()
          Returns a bid.
 java.util.List getCards()
          Returns the cards currently in the hands of the caller.
 java.util.List getCards(int direction)
          Returns the cards in one direction of the board.
 ChatChannel getChatChannel()
          This method returns the ChatChannel of this game.
 Contract getContract()
          Returns the contract being played.
 int getDeclarerTricks()
          Returns the number of tricks that the declarer made so far.
 int getDirection()
          Returns the direction of the calling player.
 java.util.List getDummyCards()
          Returns the cards of the dummy that are not played yet.
 Trick getLatestTrick()
          Returns the trick that is currently played or just finished.
 int getOpener()
          Returns the opener of the bidding sequence.
 java.lang.String[] getPlayerNames()
          Returns the names of the plaer currently taking part in this Game.
 Result getResult()
          Returns the result of this game.
 int getStatus()
          This method returns the status of the game.
 boolean isVulnerableEastWest()
          Returns wether East and West are vulnerable.
 boolean isVulnerableNorthSouth()
          Returns wether North and South are vulnerable.
 void play(Card card)
          Play a card.
 void removeGameListener(GameListener listener)
          Removes a GameListener from this Game.
 

Field Detail

BIDDING

public static final int BIDDING
Value (returned by getStatus()) indicating that this game is in the state of bidding.

PLAYING

public static final int PLAYING
Value (returned by getStatus())indicating that this game is in the state of playing.

CLAIMING

public static final int CLAIMING
Value (returned by getStatus()) indicating that this game is in the state of claiming.

FINISHED

public static final int FINISHED
Value (returned by getStatus()) indicating that this game has ended.
Method Detail

getStatus

public int getStatus()
              throws java.rmi.RemoteException
This method returns the status of the game.
Returns:
One of the constansts BIDDING, PLAYING, FINISHED.
Throws:
java.rmi.RemoteException - if the remote call fails.

getChatChannel

public ChatChannel getChatChannel()
                           throws java.rmi.RemoteException
This method returns the ChatChannel of this game.
Returns:
ChatChannel or null if the game is finished.
Throws:
java.rmi.RemoteException - if the remote call fails.

addGameListener

public void addGameListener(GameListener listener)
                     throws java.rmi.RemoteException,
                            InvalidSessionException
Add a GameListener to this Game. The listener is invoked, when changes to the Game are made. See documentation of GameListener for details.
Parameters:
listener - the game listener.
Throws:
InvalidSessionException - when not called from within a valid session context.
java.rmi.RemoteException - if the remote call fails.

removeGameListener

public void removeGameListener(GameListener listener)
                        throws java.rmi.RemoteException,
                               InvalidSessionException
Removes a GameListener from this Game.
Parameters:
listener - the game listener.
Throws:
java.rmi.RemoteException - if the remote call fails.
InvalidSessionException - when not called from within a valid session context.

getPlayerNames

public java.lang.String[] getPlayerNames()
                                  throws java.rmi.RemoteException
Returns the names of the plaer currently taking part in this Game. Setting players is handled by the objects, that own the game (for example Table, Tournament).
Returns:
Array of Playernames. This array has the length 4, but may contain null entries if there is currently no player at that place.
Throws:
java.rmi.RemoteException - if the remote call fails.

getActivePlayer

public int getActivePlayer()
                    throws java.rmi.RemoteException,
                           InvalidGameStateException
Returns the player (direction), that is currently due to make a move. If the declarer is to play one of the dummy's cards this method returns the dummy's direction!!
Returns:
one of the Player constants (NORTH, SOUTH, EAST, WEST).
Throws:
java.rmi.RemoteException - if the remote call fails.
InvalidGameStateException - If the game is already finished.

appealToJudge

public void appealToJudge(java.lang.String reason)
                   throws java.rmi.RemoteException
Appeal to a judge. This method gives players the possibility to request a judgement for the game. A reason for this has to be stated.
Parameters:
reason - Reason for calling a judge.
Throws:
java.rmi.RemoteException - if the remote call fails.

getDirection

public int getDirection()
                 throws java.rmi.RemoteException,
                        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.
Returns:
one of the Player constante (NORTH, SOUTH, EAST, WEST).
Throws:
java.rmi.RemoteException - if the remote call fails.
KosiAccessException - if the player is not currently seated at this game and therefor has no direction assigned.
InvalidSessionException - if not called from a valid session context.

getOpener

public int getOpener()
              throws java.rmi.RemoteException
Returns the opener of the bidding sequence.
Returns:
one of the Player constante (NORTH, SOUTH, EAST, WEST).
Throws:
java.rmi.RemoteException - if the remote call fails.

isVulnerableNorthSouth

public boolean isVulnerableNorthSouth()
                               throws java.rmi.RemoteException
Returns wether North and South are vulnerable.
Returns:
true if North and South are vulnerable.
Throws:
java.rmi.RemoteException - if the remote call fails.

isVulnerableEastWest

public boolean isVulnerableEastWest()
                             throws java.rmi.RemoteException
Returns wether East and West are vulnerable.
Returns:
true if East and West are vulnerable.
Throws:
java.rmi.RemoteException - if the remote call fails.

getCards

public java.util.List getCards(int direction)
                        throws InvalidGameStateException,
                               java.rmi.RemoteException
Returns the cards in one direction of the board. Only available when the game is finished or if the game has been claimed. To get your own cards or the dummy's cards, use the methods getCards() respectively getDummyCards().
Parameters:
direction - Direction the cards should be returned for.
Returns:
List of Cards.
Throws:
InvalidGameStateException - If the game is not finished yet.
java.rmi.RemoteException - If the remote call fails.

getCards

public java.util.List getCards()
                        throws java.rmi.RemoteException,
                               KosiAccessException,
                               InvalidSessionException
Returns the cards currently in the hands of the caller.
Returns:
List of Cards.
Throws:
java.rmi.RemoteException - If the remote call fails.
KosiAccessException - If the caller isn't playing this game.
InvalidSessionException - If called from an invalid session context.

getDummyCards

public java.util.List getDummyCards()
                             throws java.rmi.RemoteException,
                                    KosiAccessException,
                                    InvalidGameStateException
Returns the cards of the dummy that are not played yet.
Returns:
List of cards.
Throws:
java.rmi.RemoteException - If the remote call fails.
InvalidGameStateException - If the game's state is bidding.
KosiAccessException - If access to the dummy cards is denied.

getAlert

public Alert getAlert(int round,
                      int player)
               throws KosiAccessException,
                      InvalidGameStateException,
                      InvalidSessionException,
                      java.rmi.RemoteException
Returns an Alert.
Parameters:
round - Round the alert is returned for.
player - Player the alert is returned for.
Returns:
Alert object or null, if the bid is not alerted.
Throws:
KosiAccessException - if the calling user is not allowed to request this information.
InvalidSessionException - if not called from a valid session context.
InvalidGameStateException - if not in state of bidding.
java.rmi.RemoteException - If the remote call fails.

getBids

public java.util.List getBids()
                       throws InvalidGameStateException,
                              java.rmi.RemoteException
Returns a bid.
Parameters:
round - Round the bid is returned for.
player - Player the bid is returned for.
Returns:
A bid, or null.
Throws:
InvalidGameStateException - if not in state of bidding.
java.rmi.RemoteException - If the remote call fails.

bid

public void bid(Bid bid,
                boolean alert)
         throws java.rmi.RemoteException,
                KosiAccessException,
                InvalidGameStateException,
                InvalidBidException,
                InvalidSessionException
Bid a bid.
Parameters:
bid - Bid to bid.
alert - True, if this bid should be alerted.
Throws:
java.rmi.RemoteException - if the remote call fails.
KosiAccessException - if the calling user is not allowed to place a bid.
InvalidGameStateException - if not in state of bidding.
InvalidBidException - if the bid is not according to the bridge rules.
InvalidSessionException - if not called from a valid session context.

getContract

public Contract getContract()
                     throws java.rmi.RemoteException,
                            InvalidGameStateException
Returns the contract being played.
Returns:
Contract.
Throws:
java.rmi.RemoteException - if the remote call fails.
InvalidGameStateException - If the game's state is other than BIDDING.

getLatestTrick

public Trick getLatestTrick()
                     throws java.rmi.RemoteException,
                            InvalidGameStateException,
                            FirstTrickException
Returns the trick that is currently played or just finished.
Returns:
The trick that is currently played or just finished.
Throws:
java.rmi.RemoteException - If the remote call fails.
InvalidGameStateException - If the game's state is other than playing.
FirstTrickException - If there is no card played yet (so no trick is currently played in the point of view of the server).

play

public void play(Card card)
          throws java.rmi.RemoteException,
                 KosiAccessException,
                 InvalidCardException,
                 InvalidSessionException,
                 InvalidGameStateException
Play a card.
Parameters:
card - Card to play.
Throws:
java.rmi.RemoteException - if the remote call fails.
KosiAccessException - if the calling user is not allowed to play this card.
InvalidCardException - If the user doesn't have the card he plays or isn't following suit.
InvalidSessionException - if not called from a valid session context.
InvalidGameStateException - If the game's state is not PLAYING.

claim

public void claim(int tricks)
           throws java.rmi.RemoteException,
                  InvalidGameStateException,
                  KosiAccessException,
                  InvalidSessionException
Claim the remaining tricks.
Parameters:
tricks - number of tricks to claim.
Throws:
java.rmi.RemoteException - if the remote call fails.
InvalidGameStateException - If the game's state is not PLAYING.
KosiAccessException - If the caller is not a player of this game.

answerClaim

public void answerClaim(boolean accept)
                 throws java.rmi.RemoteException,
                        InvalidGameStateException,
                        KosiAccessException,
                        InvalidSessionException
Answer a claim.
Parameters:
accept - wether or not the claim is accepted.
Throws:
java.rmi.RemoteException - if the remote call fails.
InvalidGameStateException - If the game's state is not PLAYING.
KosiAccessException - If the caller is not a player of this game.

getResult

public Result getResult()
                 throws InvalidGameStateException,
                        java.rmi.RemoteException
Returns the result of this game.
Returns:
The result of this game.
Throws:
InvalidGameStateException - If the game hasn't been finished yet.
java.rmi.RemoteException - If RMI runs into trouble.

getDeclarerTricks

public int getDeclarerTricks()
                      throws InvalidGameStateException,
                             java.rmi.RemoteException
Returns the number of tricks that the declarer made so far.
Returns:
Number of tricks that the declarer made so far.
Throws:
InvalidGameStateException - If the game's state is BIDDING.
java.rmi.RemoteException - If RMI runs into trouble.