Added EZGameControl.restartGameIn(seconds).

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@416 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-08-23 23:19:51 +00:00
parent 71f2a1442c
commit 74665f1663
9 changed files with 97 additions and 8 deletions
@@ -55,6 +55,13 @@ public interface EZGameService extends InvocationService
*/
public void endGame (Client client, int[] winnerOids, InvocationListener listener);
/**
* Requests to start the game again in the specified number of seconds. This should only be
* used for party games. Seated table games should have each player report that they are ready
* again and the game will automatically start.
*/
public void restartGameIn (Client client, int seconds, InvocationListener listener);
/**
* Request to send a private message to one other player in the game.
*
@@ -154,8 +154,21 @@ public class EZGameMarshaller extends InvocationMarshaller
});
}
/** The method id used to dispatch {@link #restartGameIn} requests. */
public static final int RESTART_GAME_IN = 10;
// from interface EZGameService
public void restartGameIn (Client arg1, int arg2, InvocationService.InvocationListener arg3)
{
ListenerMarshaller listener3 = new ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, RESTART_GAME_IN, new Object[] {
Integer.valueOf(arg2), listener3
});
}
/** The method id used to dispatch {@link #sendMessage} requests. */
public static final int SEND_MESSAGE = 10;
public static final int SEND_MESSAGE = 11;
// from interface EZGameService
public void sendMessage (Client arg1, String arg2, Object arg3, int arg4, InvocationService.InvocationListener arg5)
@@ -168,7 +181,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #setCookie} requests. */
public static final int SET_COOKIE = 11;
public static final int SET_COOKIE = 12;
// from interface EZGameService
public void setCookie (Client arg1, byte[] arg2, InvocationService.InvocationListener arg3)
@@ -181,7 +194,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #setProperty} requests. */
public static final int SET_PROPERTY = 12;
public static final int SET_PROPERTY = 13;
// from interface EZGameService
public void setProperty (Client arg1, String arg2, Object arg3, int arg4, boolean arg5, Object arg6, InvocationService.InvocationListener arg7)
@@ -194,7 +207,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #setTicker} requests. */
public static final int SET_TICKER = 13;
public static final int SET_TICKER = 14;
// from interface EZGameService
public void setTicker (Client arg1, String arg2, int arg3, InvocationService.InvocationListener arg4)
@@ -119,6 +119,13 @@ public class EZGameDispatcher extends InvocationDispatcher
);
return;
case EZGameMarshaller.RESTART_GAME_IN:
((EZGameProvider)provider).restartGameIn(
source,
((Integer)args[0]).intValue(), (InvocationService.InvocationListener)args[1]
);
return;
case EZGameMarshaller.SEND_MESSAGE:
((EZGameProvider)provider).sendMessage(
source,
@@ -159,6 +159,28 @@ public class EZGameManager extends GameManager
endGame();
}
// from EZGameProvider
public void restartGameIn (ClientObject caller, int seconds,
InvocationService.InvocationListener listener)
throws InvocationException
{
if (_gameObj.isInPlay()) {
throw new InvocationException("e.game_in_play");
}
validateStateModification(caller, false);
// queue up the start of the next game
if (seconds > 0) {
new Interval(CrowdServer.omgr) {
public void expired () {
if (_gameObj.isActive() && !_gameObj.isInPlay()) {
startGame();
}
}
}.schedule(seconds * 1000L);
}
}
// from EZGameProvider
public void sendMessage (ClientObject caller, String msg, Object data, int playerId,
InvocationService.InvocationListener listener)
@@ -87,6 +87,12 @@ public interface EZGameProvider extends InvocationProvider
public void mergeCollection (ClientObject caller, String arg1, String arg2, InvocationService.InvocationListener arg3)
throws InvocationException;
/**
* Handles a {@link EZGameService#restartGameIn} request.
*/
public void restartGameIn (ClientObject caller, int arg1, InvocationService.InvocationListener arg2)
throws InvocationException;
/**
* Handles a {@link EZGameService#sendMessage} request.
*/