Added support for handling games with multiple rounds.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@237 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-03-11 07:59:23 +00:00
parent b6c6b74d73
commit 5b77f2f95d
11 changed files with 223 additions and 99 deletions
@@ -77,6 +77,13 @@ public class EZGameDispatcher extends InvocationDispatcher
);
return;
case EZGameMarshaller.END_ROUND:
((EZGameProvider)provider).endRound(
source,
((Integer)args[0]).intValue(), (InvocationService.InvocationListener)args[1]
);
return;
case EZGameMarshaller.END_TURN:
((EZGameProvider)provider).endTurn(
source,
@@ -110,6 +110,33 @@ public class EZGameManager extends GameManager
_turnDelegate.endTurn(nextTurnHolder);
}
// from EZGameProvider
public void endRound (ClientObject caller, int nextRoundDelay,
InvocationService.InvocationListener listener)
throws InvocationException
{
validateStateModification(caller, false);
// let the game know that it is doing something stupid
if (_gameObj.roundId < 0) {
throw new InvocationException("m.round_already_ended");
}
// while we are between rounds, our round id is the negation of the round that just ended
_gameObj.setRoundId(-_gameObj.roundId);
// queue up the start of the next round if requested
if (nextRoundDelay > 0) {
new Interval(CrowdServer.omgr) {
public void expired () {
if (_gameObj.isInPlay()) {
_gameObj.setRoundId(-_gameObj.roundId + 1);
}
}
}.schedule(nextRoundDelay * 1000L);
}
}
// from EZGameProvider
public void endGame (ClientObject caller, int[] winnerOids,
InvocationService.InvocationListener listener)
@@ -51,6 +51,12 @@ public interface EZGameProvider extends InvocationProvider
public void endGame (ClientObject caller, int[] arg1, InvocationService.InvocationListener arg2)
throws InvocationException;
/**
* Handles a {@link EZGameService#endRound} request.
*/
public void endRound (ClientObject caller, int arg1, InvocationService.InvocationListener arg2)
throws InvocationException;
/**
* Handles a {@link EZGameService#endTurn} request.
*/