Starting to rebuild with the ActionScript generator.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@90 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2006-10-04 21:26:04 +00:00
parent 022f77a08b
commit 0767b42f37
2 changed files with 58 additions and 51 deletions
+42 -39
View File
@@ -46,7 +46,7 @@ import com.threerings.parlor.game.data.PartyGameConfig;
* the Parlor services. * the Parlor services.
*/ */
public class Table public class Table
implements Hashable, DSet_Entry implements DSet_Entry, Hashable
{ {
/** The unique identifier for this table. */ /** The unique identifier for this table. */
public var tableId :int; public var tableId :int;
@@ -61,11 +61,11 @@ public class Table
/** An array of the usernames of the occupants of this table (some /** An array of the usernames of the occupants of this table (some
* slots may not be filled), or null if a party game. */ * slots may not be filled), or null if a party game. */
public var occupants :TypedArray /* of Name */; public var occupants :TypedArray;
/** The body oids of the occupants of this table, or null if a party game. /** The body oids of the occupants of this table, or null if a party game.
* (This is not propagated to remote instances.) */ * (This is not propagated to remote instances.) */
public var bodyOids :TypedArray /* of int */; public var bodyOids :TypedArray;
/** The game config for the game that is being matchmade. */ /** The game config for the game that is being matchmade. */
public var config :GameConfig; public var config :GameConfig;
@@ -78,19 +78,6 @@ public class Table
{ {
} }
/**
* 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;
}
/** /**
* Count the number of players currently occupying this table. * Count the number of players currently occupying this table.
*/ */
@@ -313,8 +300,8 @@ public class Table
return gameOid != -1; return gameOid != -1;
} }
// documentation inherited // from Hashable
public function getKey () :Object public function hashCode () :int
{ {
return tableId; return tableId;
} }
@@ -326,21 +313,36 @@ public class Table
(tableId == (other as Table).tableId); (tableId == (other as Table).tableId);
} }
// from Hashable /**
public function hashCode () :int * Generates a string representation of this table instance.
*/
public function toString () :String
{
var buf :StringBuilder = new StringBuilder();
buf.append(ClassUtil.shortClassName(this));
buf.append(" [");
toStringBuilder(buf);
buf.append("]");
return buf.toString();
}
// documentation inherited
public function getKey () :Object
{ {
return tableId; return tableId;
} }
// from Streamable /**
public function writeObject (out :ObjectOutputStream) :void * Returns true if there is no one sitting at this table.
*/
public function isEmpty () :Boolean
{ {
out.writeInt(tableId); for (var ii :int = 0; ii < bodyOids.length; ii++) {
out.writeInt(lobbyOid); if ((bodyOids[ii] as int) !== 0) {
out.writeInt(gameOid); return false;
out.writeObject(occupants); }
out.writeObject(config); }
out.writeObject(tconfig); return true;
} }
// from Streamable // from Streamable
@@ -354,23 +356,21 @@ public class Table
tconfig = (ins.readObject() as TableConfig); tconfig = (ins.readObject() as TableConfig);
} }
/** // from Streamable
* Generates a string representation of this table instance. public function writeObject (out :ObjectOutputStream) :void
*/
public function toString () :String
{ {
var buf :StringBuilder = new StringBuilder(); out.writeInt(tableId);
buf.append(ClassUtil.shortClassName(this)); out.writeInt(lobbyOid);
buf.append(" ["); out.writeInt(gameOid);
toStringBuf(buf); out.writeObject(occupants);
buf.append("]"); out.writeObject(config);
return buf.toString(); out.writeObject(tconfig);
} }
/** /**
* Helper method for toString, ripe for overrideability. * Helper method for toString, ripe for overrideability.
*/ */
protected function toStringBuf (buf :StringBuilder) :void protected function toStringBuilder (buf :StringBuilder) :void
{ {
buf.append("tableId=").append(tableId); buf.append("tableId=").append(tableId);
buf.append(", lobbyOid=").append(lobbyOid); buf.append(", lobbyOid=").append(lobbyOid);
@@ -378,5 +378,8 @@ public class Table
buf.append(", occupants=").append(occupants.join()); buf.append(", occupants=").append(occupants.join());
buf.append(", config=").append(config); buf.append(", config=").append(config);
} }
/** A counter for assigning table ids. */
protected static var _tableIdCounter :int = 0;
} }
} }
@@ -2,8 +2,8 @@
// $Id: TableConfig.java 3604 2005-06-17 20:25:28Z ray $ // $Id: TableConfig.java 3604 2005-06-17 20:25:28Z ray $
// //
// Narya library - tools for developing networked games // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/ // http://www.threerings.net/code/vilya/
// //
// This library is free software; you can redistribute it and/or modify it // This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published // under the terms of the GNU Lesser General Public License as published
@@ -23,15 +23,14 @@ package com.threerings.parlor.data {
import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.SimpleStreamableObject;
import com.threerings.io.TypedArray; import com.threerings.io.TypedArray;
/** /**
* Table configuration parameters for a game that is to be matchmade * Table configuration parameters for a game that is to be matchmade
* using the table services. * using the table services.
*/ */
public class TableConfig public class TableConfig extends SimpleStreamableObject
implements Streamable
{ {
/** The total number of players that are desired for the table, /** 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 * or -1 for a party game. For team games, this should be set to the
@@ -51,22 +50,27 @@ public class TableConfig
/** Whether the table is "private". */ /** Whether the table is "private". */
public var privateTable :Boolean; public var privateTable :Boolean;
// from Streamable public function TableConfig ()
public function writeObject (out :ObjectOutputStream) :void
{ {
out.writeInt(desiredPlayerCount); // nothing needed
out.writeInt(minimumPlayerCount);
out.writeObject(teamMemberIndices);
out.writeBoolean(privateTable);
} }
// from Streamable // from Streamable
public function readObject (ins :ObjectInputStream) :void override public function readObject (ins :ObjectInputStream) :void
{ {
desiredPlayerCount = ins.readInt(); desiredPlayerCount = ins.readInt();
minimumPlayerCount = ins.readInt(); minimumPlayerCount = ins.readInt();
teamMemberIndices = (ins.readObject() as TypedArray); teamMemberIndices = (ins.readObject() as TypedArray);
privateTable = ins.readBoolean(); privateTable = ins.readBoolean();
} }
// from Streamable
override public function writeObject (out :ObjectOutputStream) :void
{
out.writeInt(desiredPlayerCount);
out.writeInt(minimumPlayerCount);
out.writeObject(teamMemberIndices);
out.writeBoolean(privateTable);
}
} }
} }