diff --git a/src/as/com/threerings/parlor/data/Table.as b/src/as/com/threerings/parlor/data/Table.as index a6d0dc6a..85fe1a18 100644 --- a/src/as/com/threerings/parlor/data/Table.as +++ b/src/as/com/threerings/parlor/data/Table.as @@ -79,17 +79,17 @@ public class Table } /** - * Count the number of players currently occupying this table. + * Get the type of party game being played at this table, or + * PartyGameCodes.NOT_PARTY_GAME. */ - public function getOccupiedCount () :int + public function getPartyGameType () :int { - var count :int = 0; - for (var ii :int = 0; ii < occupants.length; ii++) { - if (occupants[ii] != null) { - count++; - } + if (config is PartyGameConfig) { + return (config as PartyGameConfig).getPartyGameType(); + + } else { + return PartyGameCodes.NOT_PARTY_GAME; } - return count; } /** @@ -116,6 +116,20 @@ public class Table return players; } + /** + * Count the number of players currently occupying this table. + */ + public function getOccupiedCount () :int + { + var count :int = 0; + for (var ii :int = 0; ii < occupants.length; ii++) { + if (occupants[ii] != null) { + count++; + } + } + return count; + } + /** * For a team game, get the team member indices of the compressed * players array returned by getPlayers(). @@ -154,20 +168,6 @@ public class Table return (PartyGameCodes.NOT_PARTY_GAME != getPartyGameType()); } - /** - * Get the type of party game being played at this table, or - * PartyGameCodes.NOT_PARTY_GAME. - */ - public function getPartyGameType () :int - { - if (config is PartyGameConfig) { - return (config as PartyGameConfig).getPartyGameType(); - - } else { - return PartyGameCodes.NOT_PARTY_GAME; - } - } - /** * Requests to seat the specified user at the specified position in * this table. diff --git a/src/as/com/threerings/parlor/game/data/GameAI.as b/src/as/com/threerings/parlor/game/data/GameAI.as index 68b8e13c..e877f7d1 100644 --- a/src/as/com/threerings/parlor/game/data/GameAI.as +++ b/src/as/com/threerings/parlor/game/data/GameAI.as @@ -5,13 +5,12 @@ package com.threerings.parlor.game.data { import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamable; +import com.threerings.io.SimpleStreamableObject; /** * Represents attributes of an AI player. */ -public class GameAI - implements Streamable +public class GameAI extends SimpleStreamableObject { /** The "personality" of the AI, which can be interpreted by * each puzzle. */ @@ -31,17 +30,17 @@ public class GameAI } // from Streamable - public function writeObject (out :ObjectOutputStream) :void - { - out.writeInt(personality); - out.writeInt(skill); - } - - // from Streamable - public function readObject (ins :ObjectInputStream) :void + override public function readObject (ins :ObjectInputStream) :void { personality = ins.readInt(); skill = ins.readInt(); } + + // from Streamable + override public function writeObject (out :ObjectOutputStream) :void + { + out.writeInt(personality); + out.writeInt(skill); + } } } diff --git a/src/as/com/threerings/parlor/game/data/GameConfig.as b/src/as/com/threerings/parlor/game/data/GameConfig.as index 1986a6e5..d4b9d483 100644 --- a/src/as/com/threerings/parlor/game/data/GameConfig.as +++ b/src/as/com/threerings/parlor/game/data/GameConfig.as @@ -68,6 +68,11 @@ public /*abstract*/ class GameConfig extends PlaceConfig * at all. */ public var ais :TypedArray = TypedArray.create(GameAI); + public function GameConfig () + { + // nothing needed + } + /** * Returns the message bundle identifier for the bundle that should be * used to translate the translatable strings used to describe the @@ -116,32 +121,6 @@ public /*abstract*/ class GameConfig extends PlaceConfig return -1; } - /** - * Returns an Array of strings that describe the configuration of this - * game. Default implementation returns an empty array. - */ - public function getDescription () :Array - { - return new Array(); // nothing by default - } - - /** - * 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; - - } else { - return false; - } - } - /** * Computes a hashcode for this game config object that supports our * {@link #equals} implementation. Objects that are equal should have @@ -165,15 +144,33 @@ public /*abstract*/ class GameConfig extends PlaceConfig return copy; } - override public function writeObject (out :ObjectOutputStream) :void + /** + * 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 { - super.writeObject(out); + // make sure they're of the same class + if (ClassUtil.isSameClass(other, this)) { + var that :GameConfig = GameConfig(other); + return this.rated == that.rated; - out.writeObject(players); - out.writeBoolean(rated); - out.writeObject(ais); + } else { + return false; + } } + /** + * Returns an Array of strings that describe the configuration of this + * game. Default implementation returns an empty array. + */ + public function getDescription () :Array + { + return new Array(); // nothing by default + } + + // from interface Streamable override public function readObject (ins :ObjectInputStream) :void { super.readObject(ins); @@ -182,5 +179,15 @@ public /*abstract*/ class GameConfig extends PlaceConfig rated = ins.readBoolean(); ais = (ins.readObject() as TypedArray); } + + // from interface Streamable + override public function writeObject (out :ObjectOutputStream) :void + { + super.writeObject(out); + + out.writeObject(players); + out.writeBoolean(rated); + out.writeObject(ais); + } } }