Make it easy for derived classes to opt-out of the no show timer; fixed
checkForNoShows() to only claim a partial no-show when one or more players have not reported readiness. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2006 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameManager.java,v 1.55 2002/11/26 09:12:10 mdb Exp $
|
// $Id: GameManager.java,v 1.56 2002/11/29 20:56:06 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.game;
|
package com.threerings.parlor.game;
|
||||||
|
|
||||||
@@ -384,8 +384,8 @@ public class GameManager extends PlaceManager
|
|||||||
ParlorSender.gameIsReady(bobj, _gameobj.getOid());
|
ParlorSender.gameIsReady(bobj, _gameobj.getOid());
|
||||||
}
|
}
|
||||||
|
|
||||||
// start up a no-show timer unless this is a party game
|
// start up a no-show timer if needed
|
||||||
if (!_gameconfig.isPartyGame()) {
|
if (needsNoShowTimer()) {
|
||||||
IntervalManager.register(new SafeInterval(CrowdServer.omgr) {
|
IntervalManager.register(new SafeInterval(CrowdServer.omgr) {
|
||||||
public void run () {
|
public void run () {
|
||||||
checkForNoShows();
|
checkForNoShows();
|
||||||
@@ -394,6 +394,16 @@ public class GameManager extends PlaceManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this game requires a no-show timer. The default
|
||||||
|
* implementation returns true for non-party games and false for party
|
||||||
|
* games. Derived classes may wish to change or augment this behavior.
|
||||||
|
*/
|
||||||
|
protected boolean needsNoShowTimer ()
|
||||||
|
{
|
||||||
|
return !_gameconfig.isPartyGame();
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void didShutdown ()
|
protected void didShutdown ()
|
||||||
{
|
{
|
||||||
@@ -468,7 +478,13 @@ public class GameManager extends PlaceManager
|
|||||||
placeBecameEmpty();
|
placeBecameEmpty();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
handlePartialNoShow();
|
// do the right thing if we have any no-show players
|
||||||
|
for (int ii = 0; ii < getPlayerSlots(); ii++) {
|
||||||
|
if (!playerIsReady(ii)) {
|
||||||
|
handlePartialNoShow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,15 +772,26 @@ public class GameManager extends PlaceManager
|
|||||||
protected boolean allPlayersReady ()
|
protected boolean allPlayersReady ()
|
||||||
{
|
{
|
||||||
for (int ii = 0; ii < getPlayerSlots(); ii++) {
|
for (int ii = 0; ii < getPlayerSlots(); ii++) {
|
||||||
if (_gameobj.isOccupiedPlayer(ii) &&
|
if (!playerIsReady(ii)) {
|
||||||
(_playerOids[ii] == 0) &&
|
|
||||||
(_AIs == null || _AIs[ii] == -1)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the player at the specified slot is ready (or if
|
||||||
|
* there is meant to be no player in that slot), false if there is
|
||||||
|
* meant to be a player in the specified slot and they have not yet
|
||||||
|
* reported that they are ready.
|
||||||
|
*/
|
||||||
|
protected boolean playerIsReady (int pidx)
|
||||||
|
{
|
||||||
|
return (!_gameobj.isOccupiedPlayer(pidx) || // unoccupied slot
|
||||||
|
_playerOids[pidx] != 0 || // player is ready
|
||||||
|
(_AIs != null && _AIs[pidx] != -1)); // player is AI
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void startPartyGame (ClientObject caller)
|
public void startPartyGame (ClientObject caller)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user