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.
-
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.
-
debug
- if true, enables the printing of debug informations on the console.
-
id
- Id of this game.
-
linkPlayers
- Set of players indexed on their
GameLinkFilter
objects.
-
maxPlayers
- Maximum nomber of players
-
name
- Name of the Game
-
observers
- Set of observers that will be notified of game changes, typically the
Player
objects.
-
players
- Set of players playing in this game.
-
props
- Properties of the game, dynamically loaded at game creation.
-
server
- Server in which the game has been created.
-
Game()
- Creates a new game [DESCRIBE ME MORE]
-
addObserver(Observer)
- Adds an observer to the set of observers for this game.
-
addPlayer(Player)
- Adds the specified player in this game, so that this player is able
to play the game.
-
countObservers()
- Returns the number of observers observing this game.
-
createPlayer(String, GameLinkFilter)
- Creates a new particular
Player
for this game.
-
deleteObserver(Observer)
- Deletes an observer from the set of observers for this game.
-
deleteObservers()
- Clears the observerlist so that this game no longer has any observers.
-
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.
-
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.
-
getId()
- Returns the id of the game.
-
getMaximumPlayers()
- Returns the maximum number of players in that game.
-
getName()
- Returns the name of this game.
-
getPlayerCount()
- Returns the number of players currently playing this game.
-
getPlayers()
- Returns an enumeration of players in this game.
-
isTerminated()
- Returns whether this game has already ended or if it is still running.
-
notifyObservers(LinkFrame)
- Notifies all observers that this game has changed, giving them
the frame containing the changes.
-
removePlayer(Player)
- Removes the specified player from this game.
-
setId(Object)
- Sets the id of the game.
-
setServer(GameServer)
- Sets the server in which the game has been created.
-
setupPlayer(Player)
- [DESCRIBE ME]
-
start()
- Starts the Game [CHECK: DO WE NEED THIS?]
name
protected String name
- Name of the Game
maxPlayers
protected int maxPlayers
- Maximum nomber of players
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.
props
protected Properties props
- Properties of the game, dynamically loaded at game creation.
id
protected Object id
- Id of this game.
server
protected GameServer server
- Server in which the game has been created.
observers
protected Observable observers
- Set of observers that will be notified of game changes, typically the
Player
objects.
debug
protected boolean debug
- if true, enables the printing of debug informations on the console.
players
protected Vector players
- Set of players playing in this game.
linkPlayers
protected Hashtable linkPlayers
- Set of players indexed on their
GameLinkFilter
objects.
Game
public Game()
- Creates a new game [DESCRIBE ME MORE]
getMaximumPlayers
int getMaximumPlayers()
- Returns the maximum number of players in that game.
getName
public String getName()
- Returns the name of this game.
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.
setServer
public void setServer(GameServer server)
- Sets the server in which the game has been created.
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.
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
setupPlayer
public void setupPlayer(Player player)
- [DESCRIBE ME]
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
getPlayerCount
public int getPlayerCount()
- Returns the number of players currently playing this game.
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.
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.
start
public abstract void start()
- Starts the Game [CHECK: DO WE NEED THIS?]
getId
public Object getId()
- Returns the id of the game.
setId
public void setId(Object id)
- Sets the id of the game.
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
addObserver
public void addObserver(Observer obs)
- Adds an observer to the set of observers for this game.
- Parameters:
- obs - an observer to be added.
deleteObserver
public void deleteObserver(Observer obs)
- Deletes an observer from the set of observers for this game.
- Parameters:
- obs - the observer to be deleted
deleteObservers
public void deleteObservers()
- Clears the observerlist so that this game no longer has any observers.
countObservers
public int countObservers()
- Returns the number of observers observing this game.
- Returns:
- the number of observers observing this game.
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