The table system now supports the party game types better.
The creator of a party game isn't joining, but I think that's a problem with the msoy client... git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@168 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -29,6 +29,10 @@ public class EZGameConfig extends GameConfig
|
||||
// For now, the configData is either a classname or url.
|
||||
public var configData :String;
|
||||
|
||||
// TODO: this is separate right now, but may eventually be extracted
|
||||
// from configData? Do not read this value, use getPartyGameType()
|
||||
public var partyGameType :int = PartyGameCodes.NOT_PARTY_GAME;
|
||||
|
||||
/** If non-zero, a game id used to persistently identify the game.
|
||||
* This could be thought of as a new-style rating id. */
|
||||
public var persistentGameId:int;
|
||||
@@ -68,8 +72,7 @@ public class EZGameConfig extends GameConfig
|
||||
// from PartyGameConfig
|
||||
public function getPartyGameType () :int
|
||||
{
|
||||
// TODO
|
||||
return PartyGameCodes.NOT_PARTY_GAME;
|
||||
return partyGameType;
|
||||
}
|
||||
|
||||
override public function hashCode () :int
|
||||
@@ -93,6 +96,7 @@ public class EZGameConfig extends GameConfig
|
||||
super.readObject(ins);
|
||||
|
||||
configData = (ins.readField(String) as String);
|
||||
partyGameType = ins.readByte();
|
||||
persistentGameId = ins.readInt();
|
||||
}
|
||||
|
||||
@@ -102,6 +106,7 @@ public class EZGameConfig extends GameConfig
|
||||
super.writeObject(out);
|
||||
|
||||
out.writeField(configData);
|
||||
out.writeByte(partyGameType);
|
||||
out.writeInt(persistentGameId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,15 @@ public class Table
|
||||
|
||||
/** 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;
|
||||
public /*transient*/ var bodyOids :TypedArray;
|
||||
|
||||
/** 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. */
|
||||
public var watcherCount :int;
|
||||
|
||||
/** The game config for the game that is being matchmade. */
|
||||
public var config :GameConfig;
|
||||
@@ -84,9 +92,11 @@ public class Table
|
||||
public function getOccupiedCount () :int
|
||||
{
|
||||
var count :int = 0;
|
||||
for (var ii :int = 0; ii < occupants.length; ii++) {
|
||||
if (occupants[ii] != null) {
|
||||
count++;
|
||||
if (occupants != null) {
|
||||
for (var ii :int = 0; ii < occupants.length; ii++) {
|
||||
if (occupants[ii] != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
@@ -101,10 +111,6 @@ public class Table
|
||||
*/
|
||||
public function getPlayers () :Array
|
||||
{
|
||||
if (isPartyGame()) {
|
||||
return occupants;
|
||||
}
|
||||
|
||||
// create and populate the players array
|
||||
var players :Array = new Array();
|
||||
for (var ii :int = 0; ii < occupants.length; ii++) {
|
||||
@@ -288,7 +294,8 @@ public class Table
|
||||
*/
|
||||
public function shouldBeStarted () :Boolean
|
||||
{
|
||||
return tconfig.desiredPlayerCount <= getOccupiedCount();
|
||||
return isPartyGame() ||
|
||||
(tconfig.desiredPlayerCount <= getOccupiedCount());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,18 +339,18 @@ 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;
|
||||
}
|
||||
// /**
|
||||
// * 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
|
||||
@@ -352,6 +359,8 @@ public class Table
|
||||
lobbyOid = ins.readInt();
|
||||
gameOid = ins.readInt();
|
||||
occupants = (ins.readObject() as TypedArray);
|
||||
playerCount = ins.readShort();
|
||||
watcherCount = ins.readShort();
|
||||
config = (ins.readObject() as GameConfig);
|
||||
tconfig = (ins.readObject() as TableConfig);
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ import com.threerings.io.TypedArray;
|
||||
*/
|
||||
public class TableConfig extends SimpleStreamableObject
|
||||
{
|
||||
/** The total number of players that are desired for the table,
|
||||
* or -1 for a party game. 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
|
||||
|
||||
Reference in New Issue
Block a user