Allow additional game states.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3485 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-04-14 01:22:38 +00:00
parent ffbf3f7082
commit eda477180f
@@ -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 <code>IN_PLAY</code>
* state. This happens when all of the players have arrived and the