Files
narya/src/java/com/threerings/parlor/game/GameConfig.java
T
Michael Bayne 32dee3cbaf 405 modified source files and 17,367 lines of diffs later we now enforce
more discipline when handling names in our code base. Any user entered
name should find its way into a Name object as soon as it comes out of a
text field or whatnot, and stay that way until it makes its way into a
text field or into a database record (for which String objects are vastly
simpler because of JORA magic).

Dear God, let me never again make a change this large for the rest of my
mortal life.

Unfortunately, this means we have to keep an eye out for funny business
pretty much everywhere. However, since we will absolutely want to test
market stalls and so forth on Azure, we'll have an opportunity to iron out
any funny business that might fall under the radar during our internal
testing.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2980 542714f4-19e9-0310-aa3c-eee0fc999fb1
2004-03-06 11:29:19 +00:00

71 lines
2.5 KiB
Java

//
// $Id: GameConfig.java,v 1.17 2004/03/06 11:29:19 mdb Exp $
package com.threerings.parlor.game;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.util.Name;
/**
* 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.
*
* <p> 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 {@link
* #getControllerClass} and {@link #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.
*/
public abstract class GameConfig extends PlaceConfig
{
/** The usernames of the players involved in this game, or an empty
* array if such information is not needed by this particular game. */
public Name[] players = new Name[0];
/** Indicates whether or not this game is rated. */
public boolean rated = true;
/**
* Returns the class that should be used to create a user interface
* that can be used to configure this instance prior to starting the
* game. The configurator class must derive from {@link
* GameConfigurator}.
*/
public abstract Class getConfiguratorClass ();
/**
* Returns true if this game config object is equal to the supplied
* object (meaning it is also a game config object and its
* configuration settings are the same as ours).
*/
public boolean equals (Object other)
{
// make sure they're of the same class
if (other.getClass() == this.getClass()) {
GameConfig that = (GameConfig) other;
return this.rated == that.rated;
} else {
return false;
}
}
/**
* Computes a hashcode for this game config object that supports our
* {@link #equals} implementation. Objects that are equal should have
* the same hashcode.
*/
public int hashCode ()
{
// look ma, it's so sophisticated!
return getClass().hashCode() + (rated ? 1 : 0);
}
}