From eda477180fafce39acd80d2fde4e0ea398394850 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 14 Apr 2005 01:22:38 +0000 Subject: [PATCH] Allow additional game states. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3485 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../parlor/game/client/GameController.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/java/com/threerings/parlor/game/client/GameController.java b/src/java/com/threerings/parlor/game/client/GameController.java index 132dbb7dc..fc17e7b8e 100644 --- a/src/java/com/threerings/parlor/game/client/GameController.java +++ b/src/java/com/threerings/parlor/game/client/GameController.java @@ -200,25 +200,36 @@ public abstract class GameController extends PlaceController { // deal with game state changes if (event.getName().equals(GameObject.STATE)) { - switch (event.getIntValue()) { - case GameObject.IN_PLAY: - gameDidStart(); - break; - case GameObject.GAME_OVER: - gameDidEnd(); - break; - case GameObject.CANCELLED: - gameWasCancelled(); - break; - default: + if (!handleStateChange(event.getIntValue())) { Log.warning("Game transitioned to unknown state " + "[gobj=" + _gobj + ", state=" + event.getIntValue() + "]."); - break; } } } + /** + * Derived classes can override this method if they add additional + * game states and should handle transitions to those states, + * returning true to indicate they were handled and calling super for + * the normal game states. + */ + protected boolean handleStateChange (int state) + { + switch (state) { + case GameObject.IN_PLAY: + gameDidStart(); + return true; + case GameObject.GAME_OVER: + gameDidEnd(); + return true; + case GameObject.CANCELLED: + gameWasCancelled(); + return true; + } + return false; + } + /** * Called when the game transitions to the IN_PLAY * state. This happens when all of the players have arrived and the