All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class game.Game

java.lang.Object
   |
   +----game.Game

public abstract class Game
extends Object
implements GameLinkListener, GameLinkConstants
The Game class is the abstract class specifying what features a game that will be handled by the Jags server needs to provide. Such a game will inherit from Game and implement all the abstract methods, and if necessary override some of the concrete methods. The Game class also provides basic functonalities common to all games, such as handling the observers, adding and removing players, loading the properties, etc.


Variable Index

 o clientGameClassName
Name of the class that has to be used in the Jags client to be able to connect to this game in the Jags server.
 o debug
if true, enables the printing of debug informations on the console.
 o id
Id of this game.
 o linkPlayers
Set of players indexed on their GameLinkFilter objects.
 o maxPlayers
Maximum nomber of players
 o name
Name of the Game
 o observers
Set of observers that will be notified of game changes, typically the Player objects.
 o players
Set of players playing in this game.
 o props
Properties of the game, dynamically loaded at game creation.
 o server
Server in which the game has been created.

Constructor Index

 o Game()
Creates a new game [DESCRIBE ME MORE]

Method Index

 o addObserver(Observer)
Adds an observer to the set of observers for this game.
 o addPlayer(Player)
Adds the specified player in this game, so that this player is able to play the game.
 o countObservers()
Returns the number of observers observing this game.
 o createPlayer(String, GameLinkFilter)
Creates a new particular Player for this game.
 o deleteObserver(Observer)
Deletes an observer from the set of observers for this game.
 o deleteObservers()
Clears the observerlist so that this game no longer has any observers.
 o frameReceived(Object, LinkFrame)
Messaged when a new data frame is received by the GameLinkFilter object and this frame belongs to the groups the GameLinkListener asked to listen to.
 o getClientGameClassName()
Returns the name of the class that has to be used in the Jags client to be able to connect to this game in the Jags server.
 o getId()
Returns the id of the game.
 o getMaximumPlayers()
Returns the maximum number of players in that game.
 o getName()
Returns the name of this game.
 o getPlayerCount()
Returns the number of players currently playing this game.
 o getPlayers()
Returns an enumeration of players in this game.
 o isTerminated()
Returns whether this game has already ended or if it is still running.
 o notifyObservers(LinkFrame)
Notifies all observers that this game has changed, giving them the frame containing the changes.
 o removePlayer(Player)
Removes the specified player from this game.
 o setId(Object)
Sets the id of the game.
 o setServer(GameServer)
Sets the server in which the game has been created.
 o setupPlayer(Player)
[DESCRIBE ME]
 o start()
Starts the Game [CHECK: DO WE NEED THIS?]

Variables

 o name
 protected String name
Name of the Game

 o maxPlayers
 protected int maxPlayers
Maximum nomber of players

 o clientGameClassName
 protected String clientGameClassName
Name of the class that has to be used in the Jags client to be able to connect to this game in the Jags server.

 o props
 protected Properties props
Properties of the game, dynamically loaded at game creation.

 o id
 protected Object id
Id of this game.

 o server
 protected GameServer server
Server in which the game has been created.

 o observers
 protected Observable observers
Set of observers that will be notified of game changes, typically the Player objects.

 o debug
 protected boolean debug
if true, enables the printing of debug informations on the console.

 o players
 protected Vector players
Set of players playing in this game.

 o linkPlayers
 protected Hashtable linkPlayers
Set of players indexed on their GameLinkFilter objects.

Constructors

 o Game
 public Game()
Creates a new game [DESCRIBE ME MORE]

Methods

 o getMaximumPlayers
 int getMaximumPlayers()
Returns the maximum number of players in that game.

 o getName
 public String getName()
Returns the name of this game.

 o getClientGameClassName
 public String getClientGameClassName()
Returns the name of the class that has to be used in the Jags client to be able to connect to this game in the Jags server.

 o setServer
 public void setServer(GameServer server)
Sets the server in which the game has been created.

 o createPlayer
 public abstract Player createPlayer(String name,
                                     GameLinkFilter link)
Creates a new particular Player for this game. This method has to be overriden by children so that the created player is of the right type.

Parameters:
name - the name of the new player to create
link - the GameLinkFilter object that represents the link between the server and the client the player comes from.
Returns:
the newly created player of the right type to be used in this game.
 o addPlayer
 public void addPlayer(Player player) throws TooManyPlayersException, ClosedGameException
Adds the specified player in this game, so that this player is able to play the game.

Parameters:
player - the player to add in this game.
Throws: TooManyPlayersException
if the maximum number of players allowed in this game has already been reached.
Throws: ClosedGameException
if the game is closed (ie private).
See Also:
removePlayer
 o setupPlayer
 public void setupPlayer(Player player)
[DESCRIBE ME]

 o removePlayer
 public void removePlayer(Player player)
Removes the specified player from this game. The player won't be able to play anymore, unless it is added back to the game.

Parameters:
player - the player that has to be removed from this game.
See Also:
addPlayer
 o getPlayerCount
 public int getPlayerCount()
Returns the number of players currently playing this game.

 o getPlayers
 public Enumeration getPlayers()
Returns an enumeration of players in this game. To avoid synchronization problems, the array of players is first duplicated, then returned as an enumeration.

 o isTerminated
 public boolean isTerminated()
Returns whether this game has already ended or if it is still running. By default, a game is terminated when there are no more players, but this method should be overriden by children.

[CHECK ME. A newly created game also has 0 player ! -vm980301]

Returns:
true if the game is "dead", false otherwise.
 o start
 public abstract void start()
Starts the Game [CHECK: DO WE NEED THIS?]

 o getId
 public Object getId()
Returns the id of the game.

 o setId
 public void setId(Object id)
Sets the id of the game.

 o frameReceived
 public void frameReceived(Object link,
                           LinkFrame frame)
Messaged when a new data frame is received by the GameLinkFilter object and this frame belongs to the groups the GameLinkListener asked to listen to.

Parameters:
link - the GameLink that actually received the frame.
frame - the frame that has just been received.
See Also:
GameLink, frameReceived
 o addObserver
 public void addObserver(Observer obs)
Adds an observer to the set of observers for this game.

Parameters:
obs - an observer to be added.
 o deleteObserver
 public void deleteObserver(Observer obs)
Deletes an observer from the set of observers for this game.

Parameters:
obs - the observer to be deleted
 o deleteObservers
 public void deleteObservers()
Clears the observerlist so that this game no longer has any observers.

 o countObservers
 public int countObservers()
Returns the number of observers observing this game.

Returns:
the number of observers observing this game.
 o notifyObservers
 public void notifyObservers(LinkFrame frame)
Notifies all observers that this game has changed, giving them the frame containing the changes.

Parameters:
frame - the frame containing the changes

All Packages  Class Hierarchy  This Package  Previous  Next  Index