Allow tables to be started (by the creator) when there are at
least the minimum players present. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@106 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -60,5 +60,8 @@ public interface ParlorService extends InvocationService
|
|||||||
|
|
||||||
// from Java interface ParlorService
|
// from Java interface ParlorService
|
||||||
function startSolitaire (arg1 :Client, arg2 :GameConfig, arg3 :InvocationService_ConfirmListener) :void;
|
function startSolitaire (arg1 :Client, arg2 :GameConfig, arg3 :InvocationService_ConfirmListener) :void;
|
||||||
|
|
||||||
|
// from Java interface ParlorService
|
||||||
|
function startTableNow (arg1 :Client, arg2 :int, arg3 :int, arg4 :InvocationService_InvocationListener) :void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,22 @@ public class TableDirector extends BasicDirector
|
|||||||
_pservice.leaveTable(_pctx.getClient(), _lobby.getOid(), tableId, this);
|
_pservice.leaveTable(_pctx.getClient(), _lobby.getOid(), tableId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a request to have the specified table start now, even if
|
||||||
|
* all the seats have not yet been filled.
|
||||||
|
*/
|
||||||
|
public function startTableNow (tableId :int) :void
|
||||||
|
{
|
||||||
|
if (_lobby == null) {
|
||||||
|
log.warning("Requested to start a table but we're not " +
|
||||||
|
"currently in a place [tableId=" + tableId + "].");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pservice.startTableNow(_ctx.getClient(), _lobby.getOid(),
|
||||||
|
tableId, this);
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
override public function clientDidLogoff (event :ClientEvent) :void
|
override public function clientDidLogoff (event :ClientEvent) :void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,5 +138,18 @@ public class ParlorMarshaller extends InvocationMarshaller
|
|||||||
arg2, listener3
|
arg2, listener3
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The method id used to dispatch {@link #startTableNow} requests. */
|
||||||
|
public static const START_TABLE_NOW :int = 8;
|
||||||
|
|
||||||
|
// from interface ParlorService
|
||||||
|
public function startTableNow (arg1 :Client, arg2 :int, arg3 :int, arg4 :InvocationService_InvocationListener) :void
|
||||||
|
{
|
||||||
|
var listener4 :InvocationMarshaller_ListenerMarshaller = new InvocationMarshaller_ListenerMarshaller();
|
||||||
|
listener4.listener = arg4;
|
||||||
|
sendRequest(arg1, START_TABLE_NOW, [
|
||||||
|
Integer.valueOf(arg2), Integer.valueOf(arg3), listener4
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ public interface ParlorService extends InvocationService
|
|||||||
public void leaveTable (Client client, int lobbyOid, int tableId,
|
public void leaveTable (Client client, int lobbyOid, int tableId,
|
||||||
InvocationListener listener);
|
InvocationListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You probably don't want to call this directly, but want to call
|
||||||
|
* {@link TableDirector#startTableNow}. Requests that the specified
|
||||||
|
* table be started now, even if all seats are not occupied. This
|
||||||
|
* will always fail if called by any other player than that seated
|
||||||
|
* in position 0 (usually the creator).
|
||||||
|
*/
|
||||||
|
public void startTableNow (Client client, int lobbyOid, int tableId,
|
||||||
|
InvocationListener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests to start a single player game with the specified game
|
* Requests to start a single player game with the specified game
|
||||||
* configuration.
|
* configuration.
|
||||||
|
|||||||
@@ -214,6 +214,22 @@ public class TableDirector extends BasicDirector
|
|||||||
_pservice.leaveTable(_ctx.getClient(), _lobby.getOid(), tableId, this);
|
_pservice.leaveTable(_ctx.getClient(), _lobby.getOid(), tableId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a request to have the specified table start now, even if
|
||||||
|
* all the seats have not yet been filled.
|
||||||
|
*/
|
||||||
|
public void startTableNow (int tableId)
|
||||||
|
{
|
||||||
|
if (_lobby == null) {
|
||||||
|
Log.warning("Requested to start a table but we're not " +
|
||||||
|
"currently in a place [tableId=" + tableId + "].");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pservice.startTableNow(_ctx.getClient(), _lobby.getOid(),
|
||||||
|
tableId, this);
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void clientDidLogoff (Client client)
|
public void clientDidLogoff (Client client)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -200,4 +200,17 @@ public class ParlorMarshaller extends InvocationMarshaller
|
|||||||
arg2, listener3
|
arg2, listener3
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The method id used to dispatch {@link #startTableNow} requests. */
|
||||||
|
public static final int START_TABLE_NOW = 8;
|
||||||
|
|
||||||
|
// from interface ParlorService
|
||||||
|
public void startTableNow (Client arg1, int arg2, int arg3, InvocationService.InvocationListener arg4)
|
||||||
|
{
|
||||||
|
ListenerMarshaller listener4 = new ListenerMarshaller();
|
||||||
|
listener4.listener = arg4;
|
||||||
|
sendRequest(arg1, START_TABLE_NOW, new Object[] {
|
||||||
|
Integer.valueOf(arg2), Integer.valueOf(arg3), listener4
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,13 @@ public class ParlorDispatcher extends InvocationDispatcher
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case ParlorMarshaller.START_TABLE_NOW:
|
||||||
|
((ParlorProvider)provider).startTableNow(
|
||||||
|
source,
|
||||||
|
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (InvocationService.InvocationListener)args[2]
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
super.dispatchRequest(source, methodId, args);
|
super.dispatchRequest(source, methodId, args);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -163,6 +163,17 @@ public class ParlorProvider
|
|||||||
// themselves removed from the table they just left
|
// themselves removed from the table they just left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a {@link ParlorService#startSolitaire} request.
|
||||||
|
*/
|
||||||
|
public void startTableNow (ClientObject caller, int lobbyOid, int tableId,
|
||||||
|
InvocationService.InvocationListener listener)
|
||||||
|
throws InvocationException
|
||||||
|
{
|
||||||
|
TableManager tmgr = getTableManager(lobbyOid);
|
||||||
|
tmgr.startTableNow((BodyObject) caller, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a {@link ParlorService#startSolitaire} request.
|
* Handles a {@link ParlorService#startSolitaire} request.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -231,6 +231,40 @@ public class TableManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the specified table be started now, even if there are
|
||||||
|
* some vacant seats. This may only be done if the minimum number of
|
||||||
|
* players are already present at the table. By convention, only the
|
||||||
|
* player at seat 0 may request to have the game start early, as they
|
||||||
|
* are usually the creator.
|
||||||
|
*
|
||||||
|
* @param requester the body object of the user that wishes to start
|
||||||
|
* the table.
|
||||||
|
* @param tableId the id of the table to be started.
|
||||||
|
*
|
||||||
|
* @exception InvocationException thrown if the starting was not able
|
||||||
|
* processed for some reason. The explanation will be provided in the
|
||||||
|
* message data of the exception.
|
||||||
|
*/
|
||||||
|
public void startTableNow (BodyObject requester, int tableId)
|
||||||
|
throws InvocationException
|
||||||
|
{
|
||||||
|
// look the table up
|
||||||
|
Table table = _tables.get(tableId);
|
||||||
|
if (table == null) {
|
||||||
|
throw new InvocationException(NO_SUCH_TABLE);
|
||||||
|
|
||||||
|
} else if (requester.getOid() != table.bodyOids[0]) {
|
||||||
|
throw new InvocationException(INVALID_TABLE_POSITION);
|
||||||
|
|
||||||
|
} else if (!table.mayBeStarted()) {
|
||||||
|
throw new InvocationException(INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// I guess we're ready to go!
|
||||||
|
createGame(table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the table from all of our internal tables and from its
|
* Removes the table from all of our internal tables and from its
|
||||||
* lobby's distributed object.
|
* lobby's distributed object.
|
||||||
|
|||||||
Reference in New Issue
Block a user