From 08cc800694a257f1b90f30ad80dfef538bac8717 Mon Sep 17 00:00:00 2001 From: Ted V Date: Thu, 10 Mar 2005 00:13:25 +0000 Subject: [PATCH] Turn/GameManager now supports interface for checking whether a player is still actively playing the game. The delegate now uses this when incrementing turns to skip over players not a part of the game (rather than needing this same code in the derived classes). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3390 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/parlor/game/server/GameManager.java | 9 +++++++++ .../threerings/parlor/turn/server/TurnGameManager.java | 6 ++++++ .../parlor/turn/server/TurnGameManagerDelegate.java | 9 +++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/parlor/game/server/GameManager.java b/src/java/com/threerings/parlor/game/server/GameManager.java index f5b76600d..e77506ed7 100644 --- a/src/java/com/threerings/parlor/game/server/GameManager.java +++ b/src/java/com/threerings/parlor/game/server/GameManager.java @@ -354,6 +354,15 @@ public class GameManager extends PlaceManager return (_AIs != null && _AIs[pidx] != null); } + /** + * Returns whether the player at the specified player index is actively + * playing the game + */ + public boolean isActivePlayer (int pidx) + { + return _gameobj.isActivePlayer(pidx); + } + /** * Returns the unique round identifier for the current round. */ diff --git a/src/java/com/threerings/parlor/turn/server/TurnGameManager.java b/src/java/com/threerings/parlor/turn/server/TurnGameManager.java index 969863f58..12b28be22 100644 --- a/src/java/com/threerings/parlor/turn/server/TurnGameManager.java +++ b/src/java/com/threerings/parlor/turn/server/TurnGameManager.java @@ -66,6 +66,12 @@ public interface TurnGameManager */ public int getPlayerCount (); + /** + * Extending {@link GameManager} should automatically handle + * implementing this method. + */ + public boolean isActivePlayer (int pidx); + /** * Called when we are about to start the next turn. Implementations * can do whatever pre-start turn activities need to be done. diff --git a/src/java/com/threerings/parlor/turn/server/TurnGameManagerDelegate.java b/src/java/com/threerings/parlor/turn/server/TurnGameManagerDelegate.java index b4178c47e..5a8b04d2e 100644 --- a/src/java/com/threerings/parlor/turn/server/TurnGameManagerDelegate.java +++ b/src/java/com/threerings/parlor/turn/server/TurnGameManagerDelegate.java @@ -181,12 +181,17 @@ public class TurnGameManagerDelegate extends GameManagerDelegate return; } - // find the next occupied player slot + // find the next occupied active player slot + // + // FIXME: This might be a player that has state PLAYER_LEFT_GAME. + // It seems possible to make the GameManager track the active + // player count, not just the player count, and ignore int size = _turnGame.getPlayers().length; int oturnIdx = _turnIdx; do { _turnIdx = (_turnIdx + 1) % size; - } while (_tgmgr.getPlayerName(_turnIdx) == null); + } while (_tgmgr.getPlayerName(_turnIdx) == null || + _tgmgr.isActivePlayer(_turnIdx)); } /** The game manager for which we are delegating. */