From 223ccb86a12115204be3638878762bcba8e9f848 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 24 Sep 2008 00:56:51 +0000 Subject: [PATCH] Allow a joiner to say "any available seat". Also attempt to report errors in the TableDirector (in Flash) even though none of that is actually wired up in MSOY. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@748 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../threerings/parlor/client/TableDirector.as | 11 ++++++--- src/as/com/threerings/parlor/data/Table.as | 3 +++ .../com/threerings/parlor/data/Table.java | 23 +++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/as/com/threerings/parlor/client/TableDirector.as b/src/as/com/threerings/parlor/client/TableDirector.as index 4f22f1a3..72b91dc2 100644 --- a/src/as/com/threerings/parlor/client/TableDirector.as +++ b/src/as/com/threerings/parlor/client/TableDirector.as @@ -73,15 +73,17 @@ public class TableDirector extends BasicDirector * @param ctx the parlor context in use by the client. * @param tableField the field name of the distributed set that contains the tables we will be * managing. - * @param observer the entity that will receive callbacks when things happen to the tables. + * @param bundle the message bundle to use when reporting errors. */ - public function TableDirector (ctx :ParlorContext, tableField :String) + public function TableDirector ( + ctx :ParlorContext, tableField :String, errorBundle :String = null) { super(ctx); // keep track of this stuff _pctx = ctx; _tableField = tableField; + _errorBundle = errorBundle; } /** @@ -342,7 +344,7 @@ public class TableDirector extends BasicDirector // documentation inherited from interface public function requestFailed (reason :String) :void { - log.warning("Table action failed [reason=" + reason + "]."); + _pctx.getChatDirector().displayFeedback(_errorBundle, reason); } /** @@ -392,6 +394,9 @@ public class TableDirector extends BasicDirector /** The field name of the distributed set that contains our tables. */ protected var _tableField :String; + /** The message bundle to use when reporting errors. */ + protected var _errorBundle :String; + /** The table of which we are a member if any. */ protected var _ourTable :Table; diff --git a/src/as/com/threerings/parlor/data/Table.as b/src/as/com/threerings/parlor/data/Table.as index db9bfbcf..a6de9f64 100644 --- a/src/as/com/threerings/parlor/data/Table.as +++ b/src/as/com/threerings/parlor/data/Table.as @@ -44,6 +44,9 @@ import com.threerings.parlor.game.data.GameConfig; public class Table implements DSet_Entry, Hashable { + /** Used to request any position at a table. */ + public static const ANY_POSITION :int = -1; + /** The unique identifier for this table. */ public var tableId :int; diff --git a/src/java/com/threerings/parlor/data/Table.java b/src/java/com/threerings/parlor/data/Table.java index 2f6a7231..d4abfd0c 100644 --- a/src/java/com/threerings/parlor/data/Table.java +++ b/src/java/com/threerings/parlor/data/Table.java @@ -48,6 +48,9 @@ import com.threerings.parlor.game.data.GameObject; public class Table implements DSet.Entry, ParlorCodes { + /** Used to request any position at a table. */ + public static final int ANY_POSITION = -1; + /** The unique identifier for this table. */ public int tableId; @@ -219,6 +222,22 @@ public class Table @ActionScript(omit=true) public String setPlayer (int position, BodyObject player) { + // check whether this player has been banned + if (_bannedUsers != null && _bannedUsers.contains(player.getVisibleName())) { + return BANNED_FROM_TABLE; + } + + // if they just want any position, see if we have one available + if (position == ANY_POSITION) { + for (int ii = 0; ii < tconfig.desiredPlayerCount; ii++) { + if (players[ii] == null) { + setPlayerPos(ii, player); + return null; + } + } + return TABLE_POSITION_OCCUPIED; + } + // make sure the requested position is a valid one if (position >= tconfig.desiredPlayerCount || position < 0) { return INVALID_TABLE_POSITION; @@ -229,10 +248,6 @@ public class Table return TABLE_POSITION_OCCUPIED; } - if (_bannedUsers != null && _bannedUsers.contains(player.getVisibleName())) { - return BANNED_FROM_TABLE; - } - // otherwise all is well, stick 'em in setPlayerPos(position, player); return null;