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
@@ -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)