|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threerings.crowd.server.PlaceManager
com.threerings.parlor.game.server.GameManager
public class GameManager
The game manager handles the server side management of a game. It manipulates the game state in accordance with the logic of the game flow and generally manages the whole game playing process.
The game manager extends the place manager because games are implicitly played in a location, the players of the game implicitly bodies in that location.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.threerings.crowd.server.PlaceManager |
|---|
com.threerings.crowd.server.PlaceManager.DelegateOp, com.threerings.crowd.server.PlaceManager.MessageHandler |
| Field Summary |
|---|
| Fields inherited from interface com.threerings.parlor.data.ParlorCodes |
|---|
ALREADY_AT_TABLE, BANNED_FROM_TABLE, GAME_ALREADY_STARTED, INVALID_TABLE_POSITION, INVITATION_ACCEPTED, INVITATION_COUNTERED, INVITATION_REFUSED, INVITEE_NOT_ONLINE, MUST_BE_CREATOR, NO_SELF_BOOT, NO_SUCH_TABLE, NOT_AT_TABLE, PARLOR_GROUP, TABLE_POSITION_OCCUPIED |
| Fields inherited from interface com.threerings.parlor.game.data.GameCodes |
|---|
GAME_CHAT_TYPE, GAME_MESSAGE_BUNDLE, PLAYER_KNOCKED_OUT, WINNERS_AND_LOSERS |
| Fields inherited from interface com.threerings.presents.data.InvocationCodes |
|---|
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR |
| Constructor Summary | |
|---|---|
GameManager()
|
|
| Method Summary | |
|---|---|
int |
addPlayer(com.threerings.util.Name player)
Adds the given player to the game at the first available player index. |
boolean |
addPlayerAt(com.threerings.util.Name player,
int pidx)
Adds the given player to the game at the specified player index. |
boolean |
allPlayersReady()
Returns true if all (non-AI) players have delivered their playerReady(com.threerings.crowd.data.BodyObject)
notifications, false if they have not. |
boolean |
cancelGame()
Sets the state of the game to GameObject.CANCELLED. |
com.threerings.crowd.data.BodyObject |
checkWritePermission(com.threerings.presents.data.ClientObject client,
int playerId)
Make sure that the given caller is a player or an agent and can write to the data of the given playerId. |
void |
endGame()
Called when the game is known to be over. |
void |
endPlayerGame(int pidx)
Ends the game for the given player. |
GameConfig |
getGameConfig()
Returns the configuration object for the game being managed by this manager. |
int |
getGameId()
Returns the unique numeric identifier for our managed game. |
int |
getMatchType()
A convenience method for getting the game type. |
com.threerings.crowd.data.BodyObject |
getPlayer(int playerIdx)
Returns the user object for the player with the specified index or null if the player at that index is not online. |
int |
getPlayerCount()
Returns the number of players in the game. |
com.threerings.util.Name |
getPlayerDisplayName(int index)
Returns the name that should be shown in the client for the player with the specified index or null if no player exists at that index. |
int |
getPlayerIndex(com.threerings.util.Name username)
Returns the player index of the given user in the game, or -1 if the player is
not involved in the game. |
com.threerings.util.Name |
getPlayerName(int index)
Returns the name of the player with the specified index or null if no player exists at that index. |
int |
getPlayerOid(int index)
Returns the user object oid of the player with the specified index. |
int |
getPlayerPersistentId(com.threerings.crowd.data.BodyObject body)
Convenience for getting the persistent id from a body. |
int |
getPlayerPersistentId(com.threerings.util.Name name)
Returns the persistent user id for the supplied player name. |
int |
getPlayerSlots()
Returns the number of players allowed in this game. |
int |
getPresentPlayerIndex(int bodyOid)
Get the player index of the specified oid, or -1 if the oid is not a player or is a player that is not presently in the game. |
int |
getSessionId()
Returns the unique session identifier for this game session. |
boolean |
isActivePlayer(int pidx)
Returns whether the player at the specified player index is actively playing the game |
boolean |
isAgent(com.threerings.presents.data.ClientObject client)
Return true if the given client is a server-side agent in this place. |
boolean |
isAI(int pidx)
Returns whether the player at the specified player index is an AI. |
boolean |
isPlayer(com.threerings.presents.data.ClientObject client)
Return true if the given client is a player in this place. |
void |
occupantInRoom(com.threerings.crowd.data.BodyObject caller)
Called by the client when an occupant has arrived in the game room and has loaded their bits. |
boolean |
playerIsReady(int pidx)
Returns true if the player at the specified slot is ready (or if there is meant to be no player in that slot), false if there is meant to be a player in the specified slot and they have not yet reported that they are ready. |
void |
playerReady(com.threerings.crowd.data.BodyObject caller)
Called by the client when the player is ready for the game to start. |
boolean |
removePlayer(com.threerings.util.Name player)
Removes the given player from the game. |
void |
replacePlayer(int pidx,
com.threerings.util.Name player)
Replaces the player at the specified index and calls playerWasReplaced(int, com.threerings.util.Name, com.threerings.util.Name) to let
derived classes and delegates know what's going on. |
void |
resetGame()
Called when the game is to be reset to its starting state in preparation for a new game without actually ending the current game. |
void |
setAI(int pidx,
GameAI ai)
Sets the specified player as an AI with the specified configuration. |
boolean |
shouldConcludeGame()
Returns whether game conclusion antics such as rating updates should be performed when an in-play game is ended. |
boolean |
startGame()
This is called when the game is ready to start (all players involved have delivered their "am ready" notifications). |
void |
systemMessage(String msgbundle,
String msg)
Sends a system message to the players in the game room. |
void |
systemMessage(String msgbundle,
String msg,
boolean waitForStart)
Sends a system message to the players in the game room. |
| Methods inherited from class com.threerings.crowd.server.PlaceManager |
|---|
addDelegate, applyToDelegates, applyToOccupants, bodyWillEnter, bodyWillLeave, checkPermissions, getConfig, getLocation, getPlaceObject, init, isValidSpeaker, messageReceived, ratifyBodyEntry, registerMessageHandler, shutdown, startup, toString, updateOccupantInfo, where |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GameManager()
| Method Detail |
|---|
public GameConfig getGameConfig()
public int getGameId()
GameConfig.getGameId().
public int getMatchType()
public int addPlayer(com.threerings.util.Name player)
player - the username of the player to add to this game.
-1 if the player
could not be added to the game.
public boolean addPlayerAt(com.threerings.util.Name player,
int pidx)
player - the username of the player to add to this game.pidx - the player index at which the player is to be added.
public boolean removePlayer(com.threerings.util.Name player)
player - the username of the player to remove from this game.
public void replacePlayer(int pidx,
com.threerings.util.Name player)
playerWasReplaced(int, com.threerings.util.Name, com.threerings.util.Name) to let
derived classes and delegates know what's going on.
public com.threerings.crowd.data.BodyObject getPlayer(int playerIdx)
public void setAI(int pidx,
GameAI ai)
pidx - the player index of the AI.ai - the AI configuration.public com.threerings.util.Name getPlayerName(int index)
public com.threerings.util.Name getPlayerDisplayName(int index)
getPlayerName(int), which is the player's unique name in the server.
public int getPlayerIndex(com.threerings.util.Name username)
-1 if the player is
not involved in the game.
public int getPresentPlayerIndex(int bodyOid)
public int getPlayerOid(int index)
public int getPlayerPersistentId(com.threerings.util.Name name)
public int getPlayerPersistentId(com.threerings.crowd.data.BodyObject body)
public int getPlayerCount()
public int getPlayerSlots()
public boolean isAI(int pidx)
public boolean isActivePlayer(int pidx)
public int getSessionId()
public void systemMessage(String msgbundle,
String msg)
public void systemMessage(String msgbundle,
String msg,
boolean waitForStart)
waitForStart - if true, the message will not be sent until the game has started.public boolean startGame()
gameWillStart(), sets the necessary wheels in
motion and then calls gameDidStart(). Derived classes should override one or both of
the calldown functions (rather than this function) if they need to do things before or after
the game starts.
public void endPlayerGame(int pidx)
public void endGame()
GameObject.GAME_OVER state.
public boolean cancelGame()
GameObject.CANCELLED.
public boolean shouldConcludeGame()
public void resetGame()
gameWillReset() followed by the
standard game start processing (gameWillStart() and gameDidStart()). Derived
classes should override these calldown functions (rather than this function) if they need to
do things before or after the game resets.
public void occupantInRoom(com.threerings.crowd.data.BodyObject caller)
playerReady(com.threerings.crowd.data.BodyObject) but games that wish to delay their
actual start until players take some action must report ASAP with a call to occupantInRoom(com.threerings.crowd.data.BodyObject) to let the server know that they have arrived and will later be calling
playerReady(com.threerings.crowd.data.BodyObject) when they are ready for the game to actually start.
public void playerReady(com.threerings.crowd.data.BodyObject caller)
PlaceManager.messageReceived(com.threerings.presents.dobj.MessageEvent).
public boolean allPlayersReady()
playerReady(com.threerings.crowd.data.BodyObject)
notifications, false if they have not.
public boolean playerIsReady(int pidx)
public boolean isPlayer(com.threerings.presents.data.ClientObject client)
PlayManager
isPlayer in interface PlayManagerpublic boolean isAgent(com.threerings.presents.data.ClientObject client)
PlayManager
isAgent in interface PlayManager
public com.threerings.crowd.data.BodyObject checkWritePermission(com.threerings.presents.data.ClientObject client,
int playerId)
PlayManager
checkWritePermission in interface PlayManager
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||