com.threerings.puzzle.drop.server
Class DropManagerDelegate

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.puzzle.server.PuzzleManagerDelegate
                  extended by com.threerings.puzzle.drop.server.DropManagerDelegate
All Implemented Interfaces:
InvocationCodes, PuzzleCodes, PuzzleGameCodes, DropCodes

public abstract class DropManagerDelegate
extends PuzzleManagerDelegate
implements PuzzleCodes, DropCodes

Provides the necessary support for a puzzle game that involves a two-dimensional board containing pieces, with new pieces either falling into the board as a "drop block", or rising into the bottom of the board in new piece rows, groups of blocks can be "broken" and garbage can be sent to other players' boards as a result. This is implemented as a delegate so that the natural hierarchy need not be twisted to differentiate between puzzles that use piece dropping and those that don't. Because we have need to structure our hierarchy around things like whether a puzzle is a duty puzzle, this becomes necessary.

A puzzle game using these services will then need to extend this delegate, implementing the necessary methods to customize it for the particulars of their game and then register it with their game manager via PlaceManager.addDelegate(com.threerings.crowd.server.PlaceManagerDelegate).

It also keeps track of, for each player, board level information, and player game status. Miscellaneous utility routines are provided for checking things like whether the game is over, whether a player is still active in the game, and so forth.

Derived classes are likely to want to override getPieceDropLogic().


Field Summary
protected  int _bhei
          The board dimensions in pieces.
protected  int _bwid
          The board dimensions in pieces.
protected  DropBoard[] _dboards
          The drop game board for each player.
protected  DropConfig _dconfig
          The drop game config object.
protected  PieceDropper _dropper
          The piece dropper used to drop pieces in the board if the puzzle chooses to make use of piece dropping functionality.
protected  boolean _usedrop
          Whether the game is using drop block functionality.
protected  boolean _userise
          Whether the game is using board rising functionality.
protected static int MAX_UPDATE_LOOPS
          Used to limit the maximum number of board update loops permitted before assuming something's gone horribly awry and aborting.
 
Fields inherited from class com.threerings.puzzle.server.PuzzleManagerDelegate
_puzmgr
 
Fields inherited from class com.threerings.parlor.server.PlayManagerDelegate
_gmgr
 
Fields inherited from class com.threerings.crowd.server.PlaceManagerDelegate
_invmgr, _omgr, _plmgr
 
Fields inherited from interface com.threerings.puzzle.data.PuzzleCodes
DEBUG_PUZZLE, DEFAULT_DIFFICULTY, PUZZLE_MESSAGE_BUNDLE
 
Fields inherited from interface com.threerings.presents.data.InvocationCodes
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR
 
Fields inherited from interface com.threerings.puzzle.drop.data.DropCodes
DROP_MESSAGE_BUNDLE, DROP_STREAM, RISE_STREAM
 
Constructor Summary
DropManagerDelegate(DropLogic logic)
          Creates a drop manager delegate with a logic that it uses to determine how to manage the drop puzzle.
DropManagerDelegate(PuzzleManager puzmgr, DropLogic logic)
          Deprecated. use DropManagerDelegate(DropLogic).
 
Method Summary
 void didInit(PlaceConfig config)
           
 void didStartup(PlaceObject plobj)
           
protected  boolean dropPieces(DropBoard board)
          Drops any pieces that need dropping on the given player's board and returns whether any pieces were dropped.
 void gameWillStart()
          Called by the game manager when the game is about to start.
protected  PieceDropLogic getPieceDropLogic()
          Returns the piece drop logic used to drop any pieces that need dropping in the board.
protected  PieceDropper getPieceDropper(PieceDropLogic logic)
          Returns the piece dropper used to drop any pieces that need dropping in the board.
protected  void placedBlock(int pidx)
          This method should be called by derived classes whenever the player successfully places a drop block.
 
Methods inherited from class com.threerings.parlor.game.server.GameManagerDelegate
gameDidEnd, gameDidStart, gameWillEnd, gameWillReset, playerWasReplaced, setAI, tickAI
 
Methods inherited from class com.threerings.parlor.server.PlayManagerDelegate
isAgent, isPlayer, verifyIsPlayer, verifyIsPlayerOrAgent, verifyWritePermission
 
Methods inherited from class com.threerings.crowd.server.PlaceManagerDelegate
addDispatcher, addProvider, bodyEntered, bodyLeft, bodyUpdated, didShutdown, init, placeBecameEmpty, where
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dboards

protected DropBoard[] _dboards
The drop game board for each player.


_dconfig

protected DropConfig _dconfig
The drop game config object.


_usedrop

protected boolean _usedrop
Whether the game is using drop block functionality.


_userise

protected boolean _userise
Whether the game is using board rising functionality.


_bwid

protected int _bwid
The board dimensions in pieces.


_bhei

protected int _bhei
The board dimensions in pieces.


_dropper

protected PieceDropper _dropper
The piece dropper used to drop pieces in the board if the puzzle chooses to make use of piece dropping functionality.


MAX_UPDATE_LOOPS

protected static final int MAX_UPDATE_LOOPS
Used to limit the maximum number of board update loops permitted before assuming something's gone horribly awry and aborting.

See Also:
Constant Field Values
Constructor Detail

DropManagerDelegate

@Deprecated
public DropManagerDelegate(PuzzleManager puzmgr,
                                      DropLogic logic)
Deprecated. use DropManagerDelegate(DropLogic).


DropManagerDelegate

public DropManagerDelegate(DropLogic logic)
Creates a drop manager delegate with a logic that it uses to determine how to manage the drop puzzle.

Method Detail

didInit

public void didInit(PlaceConfig config)
Overrides:
didInit in class PuzzleManagerDelegate

didStartup

public void didStartup(PlaceObject plobj)
Overrides:
didStartup in class PlaceManagerDelegate

gameWillStart

public void gameWillStart()
Description copied from class: GameManagerDelegate
Called by the game manager when the game is about to start.

Overrides:
gameWillStart in class GameManagerDelegate

dropPieces

protected boolean dropPieces(DropBoard board)
Drops any pieces that need dropping on the given player's board and returns whether any pieces were dropped.


getPieceDropLogic

protected PieceDropLogic getPieceDropLogic()
Returns the piece drop logic used to drop any pieces that need dropping in the board.


getPieceDropper

protected PieceDropper getPieceDropper(PieceDropLogic logic)
Returns the piece dropper used to drop any pieces that need dropping in the board.


placedBlock

protected void placedBlock(int pidx)
This method should be called by derived classes whenever the player successfully places a drop block.