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
This commit is contained in:
@@ -73,15 +73,17 @@ public class TableDirector extends BasicDirector
|
|||||||
* @param ctx the parlor context in use by the client.
|
* @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
|
* @param tableField the field name of the distributed set that contains the tables we will be
|
||||||
* managing.
|
* 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);
|
super(ctx);
|
||||||
|
|
||||||
// keep track of this stuff
|
// keep track of this stuff
|
||||||
_pctx = ctx;
|
_pctx = ctx;
|
||||||
_tableField = tableField;
|
_tableField = tableField;
|
||||||
|
_errorBundle = errorBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -342,7 +344,7 @@ public class TableDirector extends BasicDirector
|
|||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public function requestFailed (reason :String) :void
|
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. */
|
/** The field name of the distributed set that contains our tables. */
|
||||||
protected var _tableField :String;
|
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. */
|
/** The table of which we are a member if any. */
|
||||||
protected var _ourTable :Table;
|
protected var _ourTable :Table;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ import com.threerings.parlor.game.data.GameConfig;
|
|||||||
public class Table
|
public class Table
|
||||||
implements DSet_Entry, Hashable
|
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. */
|
/** The unique identifier for this table. */
|
||||||
public var tableId :int;
|
public var tableId :int;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ import com.threerings.parlor.game.data.GameObject;
|
|||||||
public class Table
|
public class Table
|
||||||
implements DSet.Entry, ParlorCodes
|
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. */
|
/** The unique identifier for this table. */
|
||||||
public int tableId;
|
public int tableId;
|
||||||
|
|
||||||
@@ -219,6 +222,22 @@ public class Table
|
|||||||
@ActionScript(omit=true)
|
@ActionScript(omit=true)
|
||||||
public String setPlayer (int position, BodyObject player)
|
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
|
// make sure the requested position is a valid one
|
||||||
if (position >= tconfig.desiredPlayerCount || position < 0) {
|
if (position >= tconfig.desiredPlayerCount || position < 0) {
|
||||||
return INVALID_TABLE_POSITION;
|
return INVALID_TABLE_POSITION;
|
||||||
@@ -229,10 +248,6 @@ public class Table
|
|||||||
return TABLE_POSITION_OCCUPIED;
|
return TABLE_POSITION_OCCUPIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_bannedUsers != null && _bannedUsers.contains(player.getVisibleName())) {
|
|
||||||
return BANNED_FROM_TABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise all is well, stick 'em in
|
// otherwise all is well, stick 'em in
|
||||||
setPlayerPos(position, player);
|
setPlayerPos(position, player);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user