|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.swing.Controller
com.threerings.crowd.client.PlaceController
com.threerings.parlor.game.client.GameController
public abstract class GameController
The game controller manages the flow and control of a game on the client side. This class serves as the root of a hierarchy of controller classes that aim to provide functionality shared between various similar games. The base controller provides functionality for starting and ending the game and for calculating ratings adjustments when a game ends normally. It also handles the basic house keeping like subscription to the game object and dispatch of commands and distributed object events.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.threerings.crowd.client.PlaceController |
|---|
PlaceController.DelegateOp |
| Nested classes/interfaces inherited from class com.samskivert.swing.Controller |
|---|
Controller.ActionInvoker |
| Field Summary | |
|---|---|
protected GameConfig |
_config
Our game configuration information. |
protected ParlorContext |
_ctx
A reference to the active parlor context. |
protected boolean |
_gameOver
A local flag overriding the game over state for situations where the client knows the game is over before the server has transitioned the game object accordingly. |
protected GameObject |
_gobj
A reference to the game object for the game that we're controlling. |
| Fields inherited from class com.threerings.crowd.client.PlaceController |
|---|
_delegates, _plobj, _view |
| Fields inherited from class com.samskivert.swing.Controller |
|---|
DISPATCHER |
| Constructor Summary | |
|---|---|
GameController()
|
|
| Method Summary | |
|---|---|
void |
attributeChanged(AttributeChangedEvent event)
|
void |
didLeavePlace(PlaceObject plobj)
Removes our listener registration from the game object and cleans house. |
protected void |
gameDidEnd()
Called when the game transitions to the GAME_OVER state. |
protected void |
gameDidStart()
Called when the game transitions to the IN_PLAY state. |
protected void |
gameWasCancelled()
Called when the game was cancelled for some reason. |
protected void |
gameWillReset()
Called to give derived classes a chance to display animations, send a final packet, or do any other business they care to do when the game is about to reset. |
int |
getMatchType()
Convenience method to determine the type of game. |
int |
getSessionId()
Returns the unique session identifier for the current gameplay session. |
boolean |
handleAction(ActionEvent action)
Handles basic game controller action events. |
void |
init(CrowdContext ctx,
PlaceConfig config)
Initializes this game controller with the game configuration that was established during the match making process. |
boolean |
isGameOver()
Returns whether the game is over. |
protected void |
playerReady()
Called after we've entered the game and everything has initialized to notify the server that we, as a player, are ready to play. |
void |
resetGame()
Calls gameWillReset(), ends the current game (locally, it does not tell the server to
end the game), and waits to receive a reset notification (which is simply an event setting
the game state to IN_PLAY even though it's already set to IN_PLAY)
from the server which will start up a new game. |
void |
setGameOver(boolean gameOver)
Sets the client game over override. |
protected boolean |
stateDidChange(int state)
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. |
void |
systemMessage(String bundle,
String msg)
A way for controllers to display a game-related system message. |
void |
willEnterPlace(PlaceObject plobj)
Adds this controller as a listener to the game object (thus derived classes need not do so) and lets the game manager know that we are now ready to go. |
| Methods inherited from class com.threerings.crowd.client.PlaceController |
|---|
addDelegate, applyToDelegates, createPlaceView, createPlaceView, didInit, getPlaceConfig, getPlaceView, mayLeavePlace |
| Methods inherited from class com.samskivert.swing.Controller |
|---|
actionPerformed, configureAction, createActionButton, generateArguments, handleAction, handleAction, handleAction, postAction, postAction, postAction, setControlledPanel, wasAdded, wasRemoved |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ParlorContext _ctx
protected GameConfig _config
protected GameObject _gobj
protected boolean _gameOver
| Constructor Detail |
|---|
public GameController()
| Method Detail |
|---|
public void init(CrowdContext ctx,
PlaceConfig config)
super.init in such cases.
init in class PlaceControllerctx - the client context.config - the configuration of the game we are intended to
control.public void willEnterPlace(PlaceObject plobj)
willEnterPlace in class PlaceControllerpublic void didLeavePlace(PlaceObject plobj)
didLeavePlace in class PlaceControllerpublic int getMatchType()
public boolean isGameOver()
public void setGameOver(boolean gameOver)
public void resetGame()
gameWillReset(), ends the current game (locally, it does not tell the server to
end the game), and waits to receive a reset notification (which is simply an event setting
the game state to IN_PLAY even though it's already set to IN_PLAY)
from the server which will start up a new game. Derived classes should override gameWillReset() to perform any game-specific animations.
public int getSessionId()
public boolean handleAction(ActionEvent action)
super.handleAction for events they don't specifically handle.
handleAction in class PlaceController
public void systemMessage(String bundle,
String msg)
public void attributeChanged(AttributeChangedEvent event)
attributeChanged in interface AttributeChangeListenerprotected boolean stateDidChange(int state)
protected void playerReady()
protected void gameDidStart()
IN_PLAY state. This happens when all of
the players have arrived and the server starts the game.
protected void gameDidEnd()
GAME_OVER state. This happens when the
game reaches some end condition by normal means (is not cancelled or aborted).
protected void gameWasCancelled()
protected void gameWillReset()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||