From 74665f1663b3962a1638b842067ccef907e8d93c Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 23 Aug 2007 23:19:51 +0000 Subject: [PATCH] Added EZGameControl.restartGameIn(seconds). git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@416 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/as/com/threerings/ezgame/EZGameControl.as | 10 +++++++++ .../threerings/ezgame/client/EZGameService.as | 3 +++ .../ezgame/client/GameControlBackend.as | 8 +++++++ .../ezgame/data/EZGameMarshaller.as | 21 ++++++++++++++---- .../ezgame/client/EZGameService.java | 7 ++++++ .../ezgame/data/EZGameMarshaller.java | 21 ++++++++++++++---- .../ezgame/server/EZGameDispatcher.java | 7 ++++++ .../ezgame/server/EZGameManager.java | 22 +++++++++++++++++++ .../ezgame/server/EZGameProvider.java | 6 +++++ 9 files changed, 97 insertions(+), 8 deletions(-) diff --git a/src/as/com/threerings/ezgame/EZGameControl.as b/src/as/com/threerings/ezgame/EZGameControl.as index 69c60424..f6388718 100644 --- a/src/as/com/threerings/ezgame/EZGameControl.as +++ b/src/as/com/threerings/ezgame/EZGameControl.as @@ -596,6 +596,16 @@ public class EZGameControl extends BaseControl callEZCode("endGame_v2", winnerIds); } + /** + * 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 function restartGameIn (seconds :int) :void + { + callEZCode("restartGameIn_v1", seconds); + } + /** * Populate any properties or functions we want to expose to the other side of the ezgame * security boundary. diff --git a/src/as/com/threerings/ezgame/client/EZGameService.as b/src/as/com/threerings/ezgame/client/EZGameService.as index 755ac8d3..0b4aafe2 100644 --- a/src/as/com/threerings/ezgame/client/EZGameService.as +++ b/src/as/com/threerings/ezgame/client/EZGameService.as @@ -64,6 +64,9 @@ public interface EZGameService extends InvocationService // from Java interface EZGameService function mergeCollection (arg1 :Client, arg2 :String, arg3 :String, arg4 :InvocationService_InvocationListener) :void; + // from Java interface EZGameService + function restartGameIn (arg1 :Client, arg2 :int, arg3 :InvocationService_InvocationListener) :void; + // from Java interface EZGameService function sendMessage (arg1 :Client, arg2 :String, arg3 :Object, arg4 :int, arg5 :InvocationService_InvocationListener) :void; diff --git a/src/as/com/threerings/ezgame/client/GameControlBackend.as b/src/as/com/threerings/ezgame/client/GameControlBackend.as index 30fc823a..04082067 100644 --- a/src/as/com/threerings/ezgame/client/GameControlBackend.as +++ b/src/as/com/threerings/ezgame/client/GameControlBackend.as @@ -504,6 +504,7 @@ public class GameControlBackend o["endTurn_v2"] = endTurn_v2; o["endRound_v1"] = endRound_v1; o["endGame_v2"] = endGame_v2; + o["restartGameIn_v1"] = restartGameIn_v1; o["getTurnHolder_v1"] = getTurnHolder_v1; o["getRound_v1"] = getRound_v1; o["getOccupantName_v1"] = getOccupantName_v1; @@ -762,6 +763,13 @@ public class GameControlBackend _ctx.getClient(), toTypedIntArray(winnerIds), createLoggingConfirmListener("endGame")); } + protected function restartGameIn_v1 (seconds :int) :void + { + validateConnected(); + _ezObj.ezGameService.restartGameIn( + _ctx.getClient(), seconds, createLoggingConfirmListener("restartGameIn")); + } + protected function getDictionaryLetterSet_v1 ( locale :String, count :int, callback :Function) :void { diff --git a/src/as/com/threerings/ezgame/data/EZGameMarshaller.as b/src/as/com/threerings/ezgame/data/EZGameMarshaller.as index 0d169e0a..7e75f5a5 100644 --- a/src/as/com/threerings/ezgame/data/EZGameMarshaller.as +++ b/src/as/com/threerings/ezgame/data/EZGameMarshaller.as @@ -162,8 +162,21 @@ public class EZGameMarshaller extends InvocationMarshaller ]); } + /** The method id used to dispatch {@link #restartGameIn} requests. */ + public static const RESTART_GAME_IN :int = 10; + + // from interface EZGameService + public function restartGameIn (arg1 :Client, arg2 :int, arg3 :InvocationService_InvocationListener) :void + { + var listener3 :InvocationMarshaller_ListenerMarshaller = new InvocationMarshaller_ListenerMarshaller(); + listener3.listener = arg3; + sendRequest(arg1, RESTART_GAME_IN, [ + Integer.valueOf(arg2), listener3 + ]); + } + /** The method id used to dispatch {@link #sendMessage} requests. */ - public static const SEND_MESSAGE :int = 10; + public static const SEND_MESSAGE :int = 11; // from interface EZGameService public function sendMessage (arg1 :Client, arg2 :String, arg3 :Object, arg4 :int, arg5 :InvocationService_InvocationListener) :void @@ -176,7 +189,7 @@ public class EZGameMarshaller extends InvocationMarshaller } /** The method id used to dispatch {@link #setCookie} requests. */ - public static const SET_COOKIE :int = 11; + public static const SET_COOKIE :int = 12; // from interface EZGameService public function setCookie (arg1 :Client, arg2 :ByteArray, arg3 :InvocationService_InvocationListener) :void @@ -189,7 +202,7 @@ public class EZGameMarshaller extends InvocationMarshaller } /** The method id used to dispatch {@link #setProperty} requests. */ - public static const SET_PROPERTY :int = 12; + public static const SET_PROPERTY :int = 13; // from interface EZGameService public function setProperty (arg1 :Client, arg2 :String, arg3 :Object, arg4 :int, arg5 :Boolean, arg6 :Object, arg7 :InvocationService_InvocationListener) :void @@ -202,7 +215,7 @@ public class EZGameMarshaller extends InvocationMarshaller } /** The method id used to dispatch {@link #setTicker} requests. */ - public static const SET_TICKER :int = 13; + public static const SET_TICKER :int = 14; // from interface EZGameService public function setTicker (arg1 :Client, arg2 :String, arg3 :int, arg4 :InvocationService_InvocationListener) :void diff --git a/src/java/com/threerings/ezgame/client/EZGameService.java b/src/java/com/threerings/ezgame/client/EZGameService.java index 41276aa4..dd8cce4c 100644 --- a/src/java/com/threerings/ezgame/client/EZGameService.java +++ b/src/java/com/threerings/ezgame/client/EZGameService.java @@ -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. * diff --git a/src/java/com/threerings/ezgame/data/EZGameMarshaller.java b/src/java/com/threerings/ezgame/data/EZGameMarshaller.java index a7d3242a..aef97ef6 100644 --- a/src/java/com/threerings/ezgame/data/EZGameMarshaller.java +++ b/src/java/com/threerings/ezgame/data/EZGameMarshaller.java @@ -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) diff --git a/src/java/com/threerings/ezgame/server/EZGameDispatcher.java b/src/java/com/threerings/ezgame/server/EZGameDispatcher.java index 8df3cf28..f6dcac42 100644 --- a/src/java/com/threerings/ezgame/server/EZGameDispatcher.java +++ b/src/java/com/threerings/ezgame/server/EZGameDispatcher.java @@ -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, diff --git a/src/java/com/threerings/ezgame/server/EZGameManager.java b/src/java/com/threerings/ezgame/server/EZGameManager.java index 0c4a68ad..7b6e4037 100644 --- a/src/java/com/threerings/ezgame/server/EZGameManager.java +++ b/src/java/com/threerings/ezgame/server/EZGameManager.java @@ -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) diff --git a/src/java/com/threerings/ezgame/server/EZGameProvider.java b/src/java/com/threerings/ezgame/server/EZGameProvider.java index 59573eef..aa3f505f 100644 --- a/src/java/com/threerings/ezgame/server/EZGameProvider.java +++ b/src/java/com/threerings/ezgame/server/EZGameProvider.java @@ -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. */