com.threerings.parlor.turn.server
Class TurnGameManagerDelegate

java.lang.Object
  extended by com.threerings.crowd.server.PlaceManagerDelegate
      extended by com.threerings.parlor.server.PlayManagerDelegate
          extended by com.threerings.parlor.game.server.GameManagerDelegate
              extended by com.threerings.parlor.turn.server.TurnGameManagerDelegate
Direct Known Subclasses:
TrickCardGameManagerDelegate

public class TurnGameManagerDelegate
extends GameManagerDelegate

Performs the server-side turn-based game processing for a turn based game. Game managers which wish to make use of the turn services must implement TurnGameManager and either create an instance of this class, or an instance of a derivation which customizes the behavior, either of which would be passed to PlaceManager.addDelegate(com.threerings.crowd.server.PlaceManagerDelegate) to be activated.


Constructor Summary
TurnGameManagerDelegate()
           
TurnGameManagerDelegate(TurnGameManager tgmgr)
          Deprecated. use the zero-argument constructor.
 
Method Summary
 void didInit(com.threerings.crowd.data.PlaceConfig config)
           
 void didStartup(com.threerings.crowd.data.PlaceObject plobj)
           
 void endTurn()
          Called to end the turn.
 void gameDidStart()
          This should be called from GameManager.gameDidStart() to let the turn delegate perform start of game processing.
 int getTurnHolderIndex()
          Returns the index of the current turn holder as configured in the game object.
 boolean isPlayersTurn(int playerIndex)
          Test if it's the inputted player's turn.
 void playerWasReplaced(int pidx, com.threerings.util.Name oplayer, com.threerings.util.Name nplayer)
          Called when a player in the game has been replaced by a call to GameManager.replacePlayer(int, com.threerings.util.Name).
 void startTurn()
          Called to start the next turn.
 
Methods inherited from class com.threerings.parlor.game.server.GameManagerDelegate
gameDidEnd, gameWillEnd, gameWillReset, gameWillStart, setAI, tickAI
 
Methods inherited from class com.threerings.crowd.server.PlaceManagerDelegate
bodyEntered, bodyLeft, bodyUpdated, didShutdown, init, placeBecameEmpty, where
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurnGameManagerDelegate

public TurnGameManagerDelegate()

TurnGameManagerDelegate

@Deprecated
public TurnGameManagerDelegate(TurnGameManager tgmgr)
Deprecated. use the zero-argument constructor.

Method Detail

getTurnHolderIndex

public int getTurnHolderIndex()
Returns the index of the current turn holder as configured in the game object.

Returns:
the index into the players array of the current turn holder or -1 if there is no current turn holder.

isPlayersTurn

public boolean isPlayersTurn(int playerIndex)
Test if it's the inputted player's turn.


startTurn

public void startTurn()
Called to start the next turn. It calls TurnGameManager.turnWillStart() to allow our owning manager to perform any pre-start turn processing, sets the turn holder that was configured either when the game started or when finishing up the last turn, and then calls TurnGameManager.turnDidStart() to allow the manager to perform any post-start turn processing. This assumes that a valid turn holder has been assigned. If some pre-game preparation needs to take place in a non-turn-based manner, this function should not be called until it is time to start the first turn.


endTurn

public void endTurn()
Called to end the turn. Whatever indication a game manager has that the turn has ended (probably the submission of a valid move of some sort by the turn holding player), it should call this function to cause this turn to end and the next to begin.

If the game is no longer in play (see TurnGameObject.isInPlay()) after having called TurnGameManager.turnDidEnd() and setNextTurnHolder(), then the next turn will not automatically be started.

If the game is in play, but the next turn should not be started immediately, the game manager should have setNextTurnHolder() set the _turnIdx field to -1 which will cause us to not start the next turn. To start things back up again it would set _turnIdx to the next turn holder and call startTurn() itself.


didInit

public void didInit(com.threerings.crowd.data.PlaceConfig config)
Overrides:
didInit in class PlayManagerDelegate

didStartup

public void didStartup(com.threerings.crowd.data.PlaceObject plobj)
Overrides:
didStartup in class com.threerings.crowd.server.PlaceManagerDelegate

playerWasReplaced

public void playerWasReplaced(int pidx,
                              com.threerings.util.Name oplayer,
                              com.threerings.util.Name nplayer)
Description copied from class: GameManagerDelegate
Called when a player in the game has been replaced by a call to GameManager.replacePlayer(int, com.threerings.util.Name).

Overrides:
playerWasReplaced in class GameManagerDelegate

gameDidStart

public void gameDidStart()
This should be called from GameManager.gameDidStart() to let the turn delegate perform start of game processing.

Overrides:
gameDidStart in class GameManagerDelegate


Copyright © 2011. All Rights Reserved.