- 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:
@@ -22,6 +22,7 @@
|
|||||||
package com.threerings.ezgame.server;
|
package com.threerings.ezgame.server;
|
||||||
|
|
||||||
import com.samskivert.util.ListUtil;
|
import com.samskivert.util.ListUtil;
|
||||||
|
import com.samskivert.util.RandomUtil;
|
||||||
|
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
@@ -46,6 +47,13 @@ public class EZGameTurnDelegate extends TurnGameManagerDelegate
|
|||||||
endTurn();
|
endTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setFirstTurnHolder ()
|
||||||
|
{
|
||||||
|
// make it nobody's turn
|
||||||
|
_turnIdx = -1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setNextTurnHolder ()
|
protected void setNextTurnHolder ()
|
||||||
{
|
{
|
||||||
@@ -55,11 +63,17 @@ public class EZGameTurnDelegate extends TurnGameManagerDelegate
|
|||||||
Name nextPlayer = _nextPlayer;
|
Name nextPlayer = _nextPlayer;
|
||||||
_nextPlayer = null;
|
_nextPlayer = null;
|
||||||
|
|
||||||
int index = ListUtil.indexOf(_turnGame.getPlayers(), _nextPlayer);
|
int index = ListUtil.indexOf(_turnGame.getPlayers(), nextPlayer);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
_turnIdx = index;
|
_turnIdx = index;
|
||||||
return;
|
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
|
// otherwise, do the default behavior
|
||||||
|
|||||||
Reference in New Issue
Block a user