From fa1c7af17a611efc6ea5e9a730b3a06b90ba76f1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 26 Nov 2003 17:46:06 +0000 Subject: [PATCH] More updates. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2882 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/puzzle/client/PuzzlePanel.java | 20 +++++++----- .../puzzle/server/PuzzleManager.java | 31 ++++++++++++------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/java/com/threerings/puzzle/client/PuzzlePanel.java b/src/java/com/threerings/puzzle/client/PuzzlePanel.java index 7eaaa48c1..e10dbddb2 100644 --- a/src/java/com/threerings/puzzle/client/PuzzlePanel.java +++ b/src/java/com/threerings/puzzle/client/PuzzlePanel.java @@ -1,5 +1,5 @@ // -// $Id: PuzzlePanel.java,v 1.1 2003/11/26 01:42:34 mdb Exp $ +// $Id: PuzzlePanel.java,v 1.2 2003/11/26 17:46:06 mdb Exp $ package com.threerings.puzzle.client; @@ -48,10 +48,6 @@ public abstract class PuzzlePanel extends JPanel _xlate = getKeyTranslator(); _ctx.getKeyboardManager().setTarget(this, _xlate); - // leave the keyboard manager disabled to start, and set things up - // for chatting - setPuzzleGrabsKeys(false); - // configure the puzzle panel setLayout(new BorderLayout()); @@ -59,12 +55,22 @@ public abstract class PuzzlePanel extends JPanel _bview = createBoardView(ctx); // create the puzzle board panel - _bpanel = createBoardPanel(); + _bpanel = createBoardPanel(ctx); // add the board panel add(_bpanel, BorderLayout.CENTER); } + // documentation inherited + public void addNotify () + { + super.addNotify(); + + // leave the keyboard manager disabled to start, and set things up + // for chatting + setPuzzleGrabsKeys(false); + } + /** * Temporarily replaces the puzzle board display with the supplied * overlay panel. The panel can be removed and the board display @@ -184,7 +190,7 @@ public abstract class PuzzlePanel extends JPanel * derived panel is responsible for making sure that the board view is * present in the board panel. */ - protected abstract JPanel createBoardPanel (); + protected abstract JPanel createBoardPanel (PuzzleContext ctx); /** * Returns a key translator with the desired key to controller command diff --git a/src/java/com/threerings/puzzle/server/PuzzleManager.java b/src/java/com/threerings/puzzle/server/PuzzleManager.java index e585904d8..84808dd13 100644 --- a/src/java/com/threerings/puzzle/server/PuzzleManager.java +++ b/src/java/com/threerings/puzzle/server/PuzzleManager.java @@ -1,5 +1,5 @@ // -// $Id: PuzzleManager.java,v 1.2 2003/11/26 02:07:45 mdb Exp $ +// $Id: PuzzleManager.java,v 1.3 2003/11/26 17:46:06 mdb Exp $ package com.threerings.puzzle.server; @@ -165,6 +165,17 @@ public abstract class PuzzleManager extends GameManager } } + /** + * Returns whether game conclusion antics such as rating updates + * should be performed when an in-play game is ended. Derived classes + * may wish to override this method to customize the conditions under + * which the game is concluded. + */ + public boolean shouldConcludeGame () + { + return (_puzobj.state == PuzzleObject.GAME_OVER); + } + /** * Called when a player has been marked as knocked out but before the * knock-out status update has been sent to the players. Any status @@ -407,6 +418,13 @@ public abstract class PuzzleManager extends GameManager // send along one final status update sendStatusUpdate(); + // report the winners and losers if appropriate + int winnerCount = _puzobj.getWinnerCount(); + boolean draw = (winnerCount == getPlayerCount()); + if (shouldConcludeGame() && winnerCount > 0 && !draw) { + reportWinnersAndLosers(); + } + super.gameDidEnd(); } @@ -470,17 +488,6 @@ public abstract class PuzzleManager extends GameManager _invmgr.clearDispatcher(_puzobj.puzzleGameService); } - /** - * Returns whether game conclusion antics such as rating updates - * should be performed when an in-play game is ended. Derived classes - * may wish to override this method to customize the conditions under - * which the game is concluded. - */ - protected boolean shouldConcludeGame () - { - return (_puzobj.state == PuzzleObject.GAME_OVER); - } - /** * Applies progress updates received from the client. If puzzle * debugging is enabled, this also compares the client board dumps