com.threerings.parlor.game.data
Class GameConfig

java.lang.Object
  extended by com.threerings.io.SimpleStreamableObject
      extended by com.threerings.crowd.data.PlaceConfig
          extended by com.threerings.parlor.game.data.GameConfig
All Implemented Interfaces:
com.threerings.io.Streamable, Cloneable

public abstract class GameConfig
extends com.threerings.crowd.data.PlaceConfig
implements Cloneable

The game config class encapsulates the configuration information for a particular type of game. The hierarchy of game config objects mimics the hierarchy of game managers and controllers. Both the game manager and game controller are provided with the game config object when the game is created.

The game config object is also the mechanism used to instantiate the appropriate game manager and controller. Every game must have an associated game config derived class that overrides PlaceConfig.createController() and PlaceConfig.getManagerClassName(), returning the appropriate game controller and manager class for that game. Thus the entire chain of events that causes a particular game to be created is the construction of the appropriate game config instance which is provided to the server as part of an invitation or via some other matchmaking mechanism.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Field Summary
 GameAI[] ais
          Configurations for AIs to be used in this game.
static int PARTY
          Matchmaking type constant: a game that starts immediately, and every user that enters is a player.
 com.threerings.util.Name[] players
          The usernames of the players involved in this game, or an empty array if such information is not needed by this particular game.
 boolean rated
          Indicates whether or not this game is rated.
static int SEATED_CONTINUOUS
          Matchmaking type constant: a game that starts immediately, but only has a certain number of player slots.
static int SEATED_GAME
          Matchmaking type constant: a game that is started with a list of players, and those are the only players that may play.
static String[] TYPE_STRINGS
          Maps the matchmaking type codes into strings used in our XML configuration.
 
Constructor Summary
GameConfig()
           
 
Method Summary
 GameConfig clone()
           
 GameConfigurator createConfigurator()
          Creates a configurator that can be used to create a user interface for configuring this instance prior to starting the game.
 TableConfigurator createTableConfigurator()
          Creates a table configurator for initializing 'table' properties of the game.
 boolean equals(Object other)
          Returns true if this game config object is equal to the supplied object (meaning it is a game config for the same game and its configuration settings are the same as ours).
 List<String> getDescription()
          Returns a List of strings that describe the configuration of this game.
abstract  int getGameId()
          Returns a numeric identifier for this game class.
abstract  String getGameIdent()
          Returns a string identifier for this game class (e.g.
 int getMatchType()
          Returns the matchmaking type of this game: SEATED_GAME, etc.
 int hashCode()
          Computes a hashcode for this game config object that supports our equals(java.lang.Object) implementation.
 
Methods inherited from class com.threerings.crowd.data.PlaceConfig
createController, getControllerClass, getManagerClassName
 
Methods inherited from class com.threerings.io.SimpleStreamableObject
toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEATED_GAME

public static final int SEATED_GAME
Matchmaking type constant: a game that is started with a list of players, and those are the only players that may play.

See Also:
Constant Field Values

SEATED_CONTINUOUS

public static final int SEATED_CONTINUOUS
Matchmaking type constant: a game that starts immediately, but only has a certain number of player slots. Users enter the game room, and then choose where to sit.

See Also:
Constant Field Values

PARTY

public static final int PARTY
Matchmaking type constant: a game that starts immediately, and every user that enters is a player.

See Also:
Constant Field Values

TYPE_STRINGS

public static final String[] TYPE_STRINGS
Maps the matchmaking type codes into strings used in our XML configuration.


players

public com.threerings.util.Name[] players
The usernames of the players involved in this game, or an empty array if such information is not needed by this particular game.


rated

public boolean rated
Indicates whether or not this game is rated.


ais

public GameAI[] ais
Configurations for AIs to be used in this game. Slots with real players should be null and slots with AIs should contain configuration for those AIs. A null array indicates no use of AIs at all.

Constructor Detail

GameConfig

public GameConfig()
Method Detail

getGameId

public abstract int getGameId()
Returns a numeric identifier for this game class. This may be used to track persisent information on a per-game basis.


getGameIdent

public abstract String getGameIdent()
Returns a string identifier for this game class (e.g. "spades"). This may be used to identify a message bundle for which to obtain translations for this game configuration and to look up the name of the game in said bundle.


getMatchType

public int getMatchType()
Returns the matchmaking type of this game: SEATED_GAME, etc.


createConfigurator

public GameConfigurator createConfigurator()
Creates a configurator that can be used to create a user interface for configuring this instance prior to starting the game. If no configuration is necessary, this method should return null.


createTableConfigurator

public TableConfigurator createTableConfigurator()
Creates a table configurator for initializing 'table' properties of the game. The default implementation returns null.


getDescription

public List<String> getDescription()
Returns a List of strings that describe the configuration of this game. Default implementation returns an empty list.


equals

public boolean equals(Object other)
Returns true if this game config object is equal to the supplied object (meaning it is a game config for the same game and its configuration settings are the same as ours).

Overrides:
equals in class Object

hashCode

public int hashCode()
Computes a hashcode for this game config object that supports our equals(java.lang.Object) implementation. Objects that are equal should have the same hashcode.

Overrides:
hashCode in class Object

clone

public GameConfig clone()
Overrides:
clone in class Object


Copyright © 2011. All Rights Reserved.