Hold on to your seats kids, it's another installment of "A Boy and His
Blowtorch". Refactored GameConfig and the EZ game framework, cleaning up some old cruft from GameConfig (which will break other projects and which I'll fix ASAP) and moved the XML based configuration system from ToyBox into EZGame. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@286 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -40,8 +40,7 @@ import com.threerings.parlor.data.ParlorCodes;
|
||||
import com.threerings.parlor.game.data.GameConfig;
|
||||
|
||||
/**
|
||||
* This class represents a table that is being used to matchmake a game by
|
||||
* the Parlor services.
|
||||
* This class represents a table that is being used to matchmake a game by the Parlor services.
|
||||
*/
|
||||
public class Table
|
||||
implements DSet_Entry, Hashable
|
||||
@@ -49,28 +48,25 @@ public class Table
|
||||
/** The unique identifier for this table. */
|
||||
public var tableId :int;
|
||||
|
||||
/** The object id of the lobby object with which this table is
|
||||
* associated. */
|
||||
/** The object id of the lobby object with which this table is associated. */
|
||||
public var lobbyOid :int;
|
||||
|
||||
/** The oid of the game that was created from this table or -1 if the
|
||||
* table is still in matchmaking mode. */
|
||||
/** The oid of the game that was created from this table or -1 if the table is still in
|
||||
* matchmaking mode. */
|
||||
public var gameOid :int = -1;
|
||||
|
||||
/** An array of the usernames of the occupants of this table (some
|
||||
* slots may not be filled), or null if a party game. */
|
||||
/** An array of the usernames of the occupants of this table (some slots may not be filled), or
|
||||
* null if a party game. */
|
||||
public var occupants :TypedArray;
|
||||
|
||||
/** The body oids of the occupants of this table, or null if a party game.
|
||||
* (This is not propagated to remote instances.) */
|
||||
public /*transient*/ var bodyOids :TypedArray;
|
||||
/** The body oids of the occupants of this table, or null if a party game. (This is not
|
||||
* propagated to remote instances.) */
|
||||
public var bodyOids :TypedArray;
|
||||
|
||||
/** For a running game, the total number of players. For FFA party games,
|
||||
* this is everyone. */
|
||||
/** For a running game, the total number of players. For FFA party games, this is everyone. */
|
||||
public var playerCount :int;
|
||||
|
||||
/** For a running game, the total number of watchers. For FFA party games,
|
||||
* this is always 0. */
|
||||
/** For a running game, the total number of watchers. For FFA party games, this is always 0. */
|
||||
public var watcherCount :int;
|
||||
|
||||
/** The game config for the game that is being matchmade. */
|
||||
@@ -84,6 +80,25 @@ public class Table
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Once a table is ready to play (see {@link #mayBeStarted} and {@link #shouldBeStarted}), the
|
||||
* players array can be fetched using this method. It will return an array containing the
|
||||
* usernames of all of the players in the game, sized properly and with each player in the
|
||||
* appropriate position.
|
||||
*/
|
||||
public function getPlayers () :Array
|
||||
{
|
||||
// create and populate the players array
|
||||
var players :Array = new Array();
|
||||
for (var ii :int = 0; ii < occupants.length; ii++) {
|
||||
if (occupants[ii] != null) {
|
||||
players.push(occupants[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of players currently occupying this table.
|
||||
*/
|
||||
@@ -101,28 +116,8 @@ public class Table
|
||||
}
|
||||
|
||||
/**
|
||||
* Once a table is ready to play (see {@link #mayBeStarted} and {@link
|
||||
* #shouldBeStarted}), the players array can be fetched using this
|
||||
* method. It will return an array containing the usernames of all of
|
||||
* the players in the game, sized properly and with each player in the
|
||||
* appropriate position.
|
||||
*/
|
||||
public function getPlayers () :Array
|
||||
{
|
||||
// create and populate the players array
|
||||
var players :Array = new Array();
|
||||
for (var ii :int = 0; ii < occupants.length; ii++) {
|
||||
if (occupants[ii] != null) {
|
||||
players.push(occupants[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a team game, get the team member indices of the compressed
|
||||
* players array returned by getPlayers().
|
||||
* For a team game, get the team member indices of the compressed players array returned by
|
||||
* getPlayers().
|
||||
*/
|
||||
public function getTeamMemberIndices () :TypedArray /* of Array of int */
|
||||
{
|
||||
@@ -150,98 +145,13 @@ public class Table
|
||||
return newTeams;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Requests to seat the specified user at the specified position in
|
||||
// * this table.
|
||||
// *
|
||||
// * @param position the position in which to seat the user.
|
||||
// * @param occupant the occupant to set.
|
||||
// *
|
||||
// * @return null if the user was successfully seated, a string error
|
||||
// * code explaining the failure if the user was not able to be seated
|
||||
// * at that position.
|
||||
// */
|
||||
// public function setOccupant (position :int, occupant :BodyObject) :String
|
||||
// {
|
||||
// // make sure the requested position is a valid one
|
||||
// if (position >= tconfig.desiredPlayerCount || position < 0) {
|
||||
// return ParlorCodes.INVALID_TABLE_POSITION;
|
||||
// }
|
||||
//
|
||||
// // make sure the requested position is not already occupied
|
||||
// if (occupants[position] != null) {
|
||||
// return ParlorCodes.TABLE_POSITION_OCCUPIED;
|
||||
// }
|
||||
//
|
||||
// // otherwise all is well, stick 'em in
|
||||
// setOccupantPos(position, occupant);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * This method is used for party games, it does no bounds checking
|
||||
// * or verification of the player's ability to join, if you are unsure
|
||||
// * you should call 'setOccupant'.
|
||||
// */
|
||||
// public function setOccupantPos (position :int, occupant :BodyObject) :void
|
||||
// {
|
||||
// occupants[position] = occupant.getVisibleName();
|
||||
// bodyOids[position] = occupant.getOid();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the specified user be removed from their seat at this
|
||||
// * table.
|
||||
// *
|
||||
// * @return true if the user was seated at the table and has now been
|
||||
// * removed, false if the user was never seated at the table in the
|
||||
// * first place.
|
||||
// */
|
||||
// public function clearOccupant (username :Name) :Boolean
|
||||
// {
|
||||
// var dex :int = ArrayUtil.indexOf(occupants, username);
|
||||
// if (dex != -1) {
|
||||
// clearOccupantPos(dex);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the user identified by the specified body object id
|
||||
// * be removed from their seat at this table.
|
||||
// *
|
||||
// * @return true if the user was seated at the table and has now been
|
||||
// * removed, false if the user was never seated at the table in the
|
||||
// * first place.
|
||||
// */
|
||||
// public function clearOccupantByOid (bodyOid :int) :Boolean
|
||||
// {
|
||||
// var dex :int = ArrayUtil.indexOf(bodyOids, bodyOid);
|
||||
// if (dex != -1) {
|
||||
// clearOccupantPos(dex);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Called to clear an occupant at the specified position.
|
||||
// * Only call this method if you know what you're doing.
|
||||
// */
|
||||
// public function clearOccupantPos (position :int) :void
|
||||
// {
|
||||
// occupants[position] = null;
|
||||
// bodyOids[position] = 0;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns true if this table has a sufficient number of occupants
|
||||
* that the game can be started.
|
||||
* Returns true if this table has a sufficient number of occupants that the game can be
|
||||
* started.
|
||||
*/
|
||||
public function mayBeStarted () :Boolean
|
||||
{
|
||||
switch (config.getGameType()) {
|
||||
switch (config.getMatchType()) {
|
||||
case GameConfig.SEATED_CONTINUOUS:
|
||||
case GameConfig.PARTY:
|
||||
return true;
|
||||
@@ -270,25 +180,23 @@ public class Table
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns true if sufficient seats are occupied that the game should
|
||||
// * be automatically started.
|
||||
// */
|
||||
// public function shouldBeStarted () :Boolean
|
||||
// {
|
||||
// switch (config.getGameType()) {
|
||||
// case GameConfig.SEATED_CONTINUOUS:
|
||||
// case GameConfig.PARTY:
|
||||
// return true;
|
||||
//
|
||||
// default:
|
||||
// return (tconfig.desiredPlayerCount <= getOccupiedCount());
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Returns true if sufficient seats are occupied that the game should be automatically started.
|
||||
*/
|
||||
public function shouldBeStarted () :Boolean
|
||||
{
|
||||
switch (config.getMatchType()) {
|
||||
case GameConfig.SEATED_CONTINUOUS:
|
||||
case GameConfig.PARTY:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return (tconfig.desiredPlayerCount <= getOccupiedCount());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this table is in play, false if it is still being
|
||||
* matchmade.
|
||||
* Returns true if this table is in play, false if it is still being matchmade.
|
||||
*/
|
||||
public function inPlay () :Boolean
|
||||
{
|
||||
@@ -304,8 +212,7 @@ public class Table
|
||||
// from Hashable
|
||||
public function equals (other :Object) :Boolean
|
||||
{
|
||||
return (other is Table) &&
|
||||
(tableId == (other as Table).tableId);
|
||||
return (other is Table) && (tableId == (other as Table).tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,19 +234,6 @@ public class Table
|
||||
return tableId;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns true if there is no one sitting at this table.
|
||||
// */
|
||||
// public function isEmpty () :Boolean
|
||||
// {
|
||||
// for (var ii :int = 0; ii < bodyOids.length; ii++) {
|
||||
// if ((bodyOids[ii] as int) !== 0) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// from Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
@@ -356,13 +250,14 @@ public class Table
|
||||
// from Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
throw new Error();
|
||||
// out.writeInt(tableId);
|
||||
// out.writeInt(lobbyOid);
|
||||
// out.writeInt(gameOid);
|
||||
// out.writeObject(occupants);
|
||||
// out.writeObject(config);
|
||||
// out.writeObject(tconfig);
|
||||
out.writeInt(tableId);
|
||||
out.writeInt(lobbyOid);
|
||||
out.writeInt(gameOid);
|
||||
out.writeObject(occupants);
|
||||
out.writeShort(playerCount);
|
||||
out.writeShort(watcherCount);
|
||||
out.writeObject(config);
|
||||
out.writeObject(tconfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,7 +268,7 @@ public class Table
|
||||
buf.append("tableId=").append(tableId);
|
||||
buf.append(", lobbyOid=").append(lobbyOid);
|
||||
buf.append(", gameOid=").append(gameOid);
|
||||
buf.append(", occupants=").append(occupants.join());
|
||||
buf.append(", occupants=").append(occupants == null ? "<null?>" : occupants.join());
|
||||
buf.append(", config=").append(config);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,24 +27,21 @@ import com.threerings.io.SimpleStreamableObject;
|
||||
import com.threerings.io.TypedArray;
|
||||
|
||||
/**
|
||||
* Table configuration parameters for a game that is to be matchmade
|
||||
* using the table services.
|
||||
* Table configuration parameters for a game that is to be matchmade using the table services.
|
||||
*/
|
||||
public class TableConfig extends SimpleStreamableObject
|
||||
{
|
||||
/** The total number of players that are desired for the table.
|
||||
* For team games, this should be set to the total number of players
|
||||
* overall, as teams may be unequal. */
|
||||
/** The total number of players that are desired for the table. For team games, this should be
|
||||
* set to the total number of players overall, as teams may be unequal. */
|
||||
public var desiredPlayerCount :int;
|
||||
|
||||
/** The minimum number of players needed overall (or per-team if a
|
||||
* team-based game) for the game to start at the creator's discretion. */
|
||||
/** The minimum number of players needed overall (or per-team if a team-based game) for the
|
||||
* game to start at the creator's discretion. */
|
||||
public var minimumPlayerCount :int;
|
||||
|
||||
/** If non-null, indicates that this is a team-based game and contains
|
||||
* the team assignments for each player. For example, a game with
|
||||
* three players in two teams- players 0 and 2 versus player 1- would
|
||||
* have { {0, 2}, {1} }; */
|
||||
/** If non-null, indicates that this is a team-based game and contains the team assignments for
|
||||
* each player. For example, a game with three players in two teams- players 0 and 2 versus
|
||||
* player 1- would have { {0, 2}, {1} }; */
|
||||
public var teamMemberIndices :TypedArray;
|
||||
|
||||
/** Whether the table is "private". */
|
||||
|
||||
@@ -31,14 +31,12 @@ import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* Provides the base from which interfaces can be built to configure games
|
||||
* prior to starting them. Derived classes would extend the base
|
||||
* configurator adding interface elements and wiring them up properly to
|
||||
* allow the user to configure an instance of their game.
|
||||
* Provides the base from which interfaces can be built to configure games prior to starting them.
|
||||
* Derived classes would extend the base configurator adding interface elements and wiring them up
|
||||
* properly to allow the user to configure an instance of their game.
|
||||
*
|
||||
* <p> Clients that use the game configurator will want to instantiate one
|
||||
* based on the class returned from the {@link GameConfig} and then
|
||||
* initialize it with a call to {@link #init}.
|
||||
* <p> Clients that use the game configurator will want to instantiate one based on the class
|
||||
* returned from the {@link GameConfig} and then initialize it with a call to {@link #init}.
|
||||
*/
|
||||
public /*abstract*/ class FlexGameConfigurator extends GameConfigurator
|
||||
{
|
||||
@@ -54,14 +52,12 @@ public /*abstract*/ class FlexGameConfigurator extends GameConfigurator
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a control to the interface. This should be the standard way
|
||||
* that configurator controls are added, but note also that external
|
||||
* entities may add their own controls that are related to the game,
|
||||
* but do not directly alter the game config, so that all the controls
|
||||
* are added in a uniform manner and are well aligned.
|
||||
* Add a control to the interface. This should be the standard way that configurator controls
|
||||
* are added, but note also that external entities may add their own controls that are related
|
||||
* to the game, but do not directly alter the game config, so that all the controls are added
|
||||
* in a uniform manner and are well aligned.
|
||||
*/
|
||||
public function addControl (
|
||||
label :UIComponent, control :UIComponent) :void
|
||||
public function addControl (label :UIComponent, control :UIComponent) :void
|
||||
{
|
||||
var item :HBox = new HBox();
|
||||
item.width = 225;
|
||||
|
||||
@@ -25,20 +25,18 @@ import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* Provides the base from which interfaces can be built to configure games
|
||||
* prior to starting them. Derived classes would extend the base
|
||||
* configurator adding interface elements and wiring them up properly to
|
||||
* allow the user to configure an instance of their game.
|
||||
* Provides the base from which interfaces can be built to configure games prior to starting
|
||||
* them. Derived classes would extend the base configurator adding interface elements and wiring
|
||||
* them up properly to allow the user to configure an instance of their game.
|
||||
*
|
||||
* <p> Clients that use the game configurator will want to instantiate one
|
||||
* based on the class returned from the {@link GameConfig} and then
|
||||
* initialize it with a call to {@link #init}.
|
||||
* <p> Clients that use the game configurator will want to instantiate one based on the class
|
||||
* returned from the {@link GameConfig} and then initialize it with a call to {@link #init}.
|
||||
*/
|
||||
public /*abstract*/ class GameConfigurator
|
||||
{
|
||||
/**
|
||||
* Initializes this game configurator, creates its user interface
|
||||
* elements and prepares it for display.
|
||||
* Initializes this game configurator, creates its user interface elements and prepares it for
|
||||
* display.
|
||||
*/
|
||||
public function init (ctx :ParlorContext) :void
|
||||
{
|
||||
@@ -57,8 +55,8 @@ public /*abstract*/ class GameConfigurator
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this configurator with its configuration. It should set up
|
||||
* all of its user interface elements to reflect the configuration.
|
||||
* Provides this configurator with its configuration. It should set up all of its user
|
||||
* interface elements to reflect the configuration.
|
||||
*/
|
||||
public function setGameConfig (config :GameConfig) :void
|
||||
{
|
||||
@@ -68,8 +66,8 @@ public /*abstract*/ class GameConfigurator
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will likely want to override this method and
|
||||
* configure their user interface elements accordingly.
|
||||
* Derived classes will likely want to override this method and configure their user interface
|
||||
* elements accordingly.
|
||||
*/
|
||||
protected function gotGameConfig () :void
|
||||
{
|
||||
@@ -86,10 +84,9 @@ public /*abstract*/ class GameConfigurator
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will want to override this method, flushing values
|
||||
* from the user interface to the game config object so that it is
|
||||
* properly configured prior to being returned to the {@link
|
||||
* #getGameConfig} caller.
|
||||
* Derived classes will want to override this method, flushing values from the user interface
|
||||
* to the game config object so that it is properly configured prior to being returned to the
|
||||
* {@link #getGameConfig} caller.
|
||||
*/
|
||||
protected function flushGameConfig () :void
|
||||
{
|
||||
|
||||
@@ -294,9 +294,9 @@ public /*abstract*/ class GameController extends PlaceController
|
||||
/**
|
||||
* Convenience method to determine the type of game.
|
||||
*/
|
||||
protected function getGameType () :int
|
||||
protected function getMatchType () :int
|
||||
{
|
||||
return _gconfig.getGameType();
|
||||
return _gconfig.getMatchType();
|
||||
}
|
||||
|
||||
/** A reference to the active parlor context. */
|
||||
|
||||
@@ -37,48 +37,43 @@ import com.threerings.parlor.client.TableConfigurator;
|
||||
import com.threerings.parlor.game.client.GameConfigurator;
|
||||
|
||||
/**
|
||||
* 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 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 #createController} 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.
|
||||
* <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 #createController} 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
|
||||
implements Cloneable, Hashable
|
||||
{
|
||||
/** Game type constant: a game that is started with a list of players,
|
||||
* and those are the only players that may play. */
|
||||
/** Game type constant: a game that is started with a list of players, and those are the only
|
||||
* players that may play. */
|
||||
public static const SEATED_GAME :int = 0;
|
||||
|
||||
/** Game 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. */
|
||||
/** Game 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. */
|
||||
public static const SEATED_CONTINUOUS :int = 1;
|
||||
|
||||
/** Game type constant: a game that starts immediately, and every
|
||||
* user that enters is a player. */
|
||||
/** Game type constant: a game that starts immediately, and every user that enters is a
|
||||
* player. */
|
||||
public static const PARTY :int = 2;
|
||||
|
||||
/** The usernames of the players involved in this game, or an empty
|
||||
* array if such information is not needed by this particular game. */
|
||||
/** The usernames of the players involved in this game, or an empty array if such information
|
||||
* is not needed by this particular game. */
|
||||
public var players :TypedArray = TypedArray.create(Name);
|
||||
|
||||
/** Indicates whether or not this game is rated. */
|
||||
public var rated :Boolean = true;
|
||||
|
||||
/** 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. */
|
||||
/** 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. */
|
||||
public var ais :TypedArray = TypedArray.create(GameAI);
|
||||
|
||||
public function GameConfig ()
|
||||
@@ -87,27 +82,31 @@ public /*abstract*/ class GameConfig extends PlaceConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of game.
|
||||
* Returns a numeric identifier for this game class. This may be used to track persisent
|
||||
* information on a per-game basis.
|
||||
*/
|
||||
public function getGameType () :int
|
||||
public function getGameId () :int
|
||||
{
|
||||
return SEATED_GAME;
|
||||
throw new Error("abstract");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message bundle identifier for the bundle that should be
|
||||
* used to translate the translatable strings used to describe the
|
||||
* game config parameters.
|
||||
*/
|
||||
public /*abstract*/ function getBundleName () :String
|
||||
public function getGameIdent () :String
|
||||
{
|
||||
throw new Error("abstract");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Get the type of game.
|
||||
*/
|
||||
public function getMatchType () :int
|
||||
{
|
||||
return SEATED_GAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public /*abstract*/ function createConfigurator () :GameConfigurator
|
||||
{
|
||||
@@ -115,8 +114,8 @@ public /*abstract*/ class GameConfig extends PlaceConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a table configurator for initializing 'table' properties
|
||||
* of the game. The default implementation returns null.
|
||||
* Creates a table configurator for initializing 'table' properties of the game. The default
|
||||
* implementation returns null.
|
||||
*/
|
||||
public function createTableConfigurator () :TableConfigurator
|
||||
{
|
||||
@@ -124,34 +123,13 @@ public /*abstract*/ class GameConfig extends PlaceConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a translatable label describing this game.
|
||||
*/
|
||||
public function getGameName () :String
|
||||
{
|
||||
// the whole getRatingTypeId(), getGameName(), getBundleName()
|
||||
// business should be cleaned up. we should have getGameIdent()
|
||||
// and everything should have a default implementation using that
|
||||
return "m." + getBundleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the game rating type, if the system uses such things.
|
||||
*/
|
||||
public function getRatingTypeId () :int
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hashcode for this game config object that supports our
|
||||
* {@link #equals} implementation. Objects that are equal should have
|
||||
* the same hashcode.
|
||||
* Computes a hashcode for this game config object that supports our {@link #equals}
|
||||
* implementation. Objects that are equal should have the same hashcode.
|
||||
*/
|
||||
public function hashCode () :int
|
||||
{
|
||||
// look ma, it's so sophisticated!
|
||||
return StringUtil.hashCode(ClassUtil.getClassName(this)) +
|
||||
(rated ? 1 : 0);
|
||||
return StringUtil.hashCode(ClassUtil.getClassName(this)) + (rated ? 1 : 0);
|
||||
}
|
||||
|
||||
// from Cloneable
|
||||
@@ -161,30 +139,27 @@ public /*abstract*/ class GameConfig extends PlaceConfig
|
||||
copy.players = this.players;
|
||||
copy.rated = this.rated;
|
||||
copy.ais = this.ais;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* 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 function equals (other :Object) :Boolean
|
||||
{
|
||||
// make sure they're of the same class
|
||||
if (ClassUtil.isSameClass(other, this)) {
|
||||
var that :GameConfig = GameConfig(other);
|
||||
return this.rated == that.rated;
|
||||
|
||||
return this.getGameId() == that.getGameId() && this.rated == that.rated;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Array of strings that describe the configuration of this
|
||||
* game. Default implementation returns an empty array.
|
||||
* Returns an Array of strings that describe the configuration of this game. Default
|
||||
* implementation returns an empty array.
|
||||
*/
|
||||
public function getDescription () :Array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user