- Start up EZGames so that it's nobody's turn.

- If the turn ends when it's nobody's turn and the user didn't specify
  who goes next, pick a random player to go next.
- Fixed ancient bug that caused a NPE, every time. Nobody tickled it
  by having a game where turns progress in a custom order.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@463 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2007-10-23 01:27:05 +00:00
parent 3fc47c0b9b
commit df72a961db
@@ -22,6 +22,7 @@
package com.threerings.ezgame.server;
import com.samskivert.util.ListUtil;
import com.samskivert.util.RandomUtil;
import com.threerings.util.Name;
@@ -46,6 +47,13 @@ public class EZGameTurnDelegate extends TurnGameManagerDelegate
endTurn();
}
@Override
protected void setFirstTurnHolder ()
{
// make it nobody's turn
_turnIdx = -1;
}
@Override
protected void setNextTurnHolder ()
{
@@ -55,11 +63,17 @@ public class EZGameTurnDelegate extends TurnGameManagerDelegate
Name nextPlayer = _nextPlayer;
_nextPlayer = null;
int index = ListUtil.indexOf(_turnGame.getPlayers(), _nextPlayer);
int index = ListUtil.indexOf(_turnGame.getPlayers(), nextPlayer);
if (index != -1) {
_turnIdx = index;
return;
}
} else if (_turnIdx == -1) {
// If it's nobody's turn, and the user does not specify a next-turn, randomize.
// We set turnIdx to the player we want - 1, so that when it gets inc'd it'll
// be right.
_turnIdx = RandomUtil.getInt(_turnGame.getPlayers().length) - 1;
}
// otherwise, do the default behavior