More stuff with ending player games:

- If a player leaves, handle the ending of their game in GameManager.
- don't start the turn first turn in turn-based games on a missing player
- Let derived classes get playerGameDidEnd() even if the game doesn't
  have statuses.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3640 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-07-01 23:56:54 +00:00
parent e1338dca1e
commit b603e6b051
4 changed files with 36 additions and 47 deletions
@@ -34,14 +34,6 @@ public interface PuzzleCodes extends InvocationCodes
/** The default puzzle difficulty level. */
public static final int DEFAULT_DIFFICULTY = 2;
/** The name of the message event to a placeObject that a player
* was knocked out of a puzzle. */
public static final String PLAYER_KNOCKED_OUT = "playerKnocked";
/** The name of the message event to a placeObject that reports
* the winners and losers of a game. */
public static final String WINNERS_AND_LOSERS = "winnersAndLosers";
/** Whether to enable debug logging and assertions for puzzles. Note
* that enabling this may result in the server or client exiting
* unexpectedly if certain error conditions arise in order to
@@ -112,20 +112,16 @@ public abstract class PuzzleManager extends GameManager
}
}
/**
* Ends the game for the given player.
*/
public void endPlayerGame (int pidx)
// documentation inherited
protected void playerGameDidEnd (int pidx)
{
// don't update board summaries for AI players since they keep
// their own board summary up to date
super.playerGameDidEnd(pidx);
if (!isAI(pidx)) {
// update the board summary with the player's final board
updateBoardSummary(pidx);
}
super.endPlayerGame(pidx);
// force a status update
updateStatus();
}
@@ -459,18 +455,6 @@ public abstract class PuzzleManager extends GameManager
return false;
}
// documentation inherited
protected void bodyLeft (int bodyOid)
{
super.bodyLeft(bodyOid);
int pidx = IntListUtil.indexOf(_playerOids, bodyOid);
if (pidx != -1 && _puzobj.isInPlay() && _puzobj.isActivePlayer(pidx)) {
// end the player's game if they bail on an in-progress puzzle
endPlayerGame(pidx);
}
}
/**
* Overrides the game manager implementation to mark all active
* players as winners. Derived classes may wish to override this