com.threerings.puzzle.drop.util
Class PieceDropper

java.lang.Object
  extended by com.threerings.puzzle.drop.util.PieceDropper
All Implemented Interfaces:
DropPieceCodes, DirectionCodes

public class PieceDropper
extends Object
implements DropPieceCodes

Handles dropping pieces in a board.


Nested Class Summary
static interface PieceDropper.DropObserver
          Called to inform a drop observer that a piece has been dropped.
static class PieceDropper.PieceDropInfo
          A class to hold information detailing the pieces to be dropped in a particular column.
 
Field Summary
protected  PieceDropLogic _logic
          Allows puzzle-specific customizations.
 
Fields inherited from interface com.threerings.puzzle.drop.data.DropPieceCodes
DROP_BLOCK_PIECE_COUNT, PIECE_NONE
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
PieceDropper(PieceDropLogic logic)
          Constructs a piece dropper that uses the supplied piece drop logic to specialize itself for a particular puzzle.
 
Method Summary
protected  void drop(DropBoard board, int piece, int xx, int yy, int ty, PieceDropper.DropObserver drobs)
          Helpy helper function.
protected  int dropPieces(DropBoard board, int xx, int yy, PieceDropper.DropObserver drobs)
          Computes and effects the drop for the specified piece and any associated attached pieces.
 int dropPieces(DropBoard board, PieceDropper.DropObserver drobs)
          Effects any drops possible on the supplied board (modifying the board in the progress) and notifying the supplied drop observer of those drops.
 int fillBoard(DropBoard board, PieceDropper.DropObserver drobs)
          Drops new pieces onto the board to fill the gaps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logic

protected PieceDropLogic _logic
Allows puzzle-specific customizations.

Constructor Detail

PieceDropper

public PieceDropper(PieceDropLogic logic)
Constructs a piece dropper that uses the supplied piece drop logic to specialize itself for a particular puzzle.

Method Detail

dropPieces

public int dropPieces(DropBoard board,
                      PieceDropper.DropObserver drobs)
Effects any drops possible on the supplied board (modifying the board in the progress) and notifying the supplied drop observer of those drops.

Returns:
the number of pieces dropped.

fillBoard

public int fillBoard(DropBoard board,
                     PieceDropper.DropObserver drobs)
Drops new pieces onto the board to fill the gaps.

Returns:
the number of pieces dropped.

dropPieces

protected int dropPieces(DropBoard board,
                         int xx,
                         int yy,
                         PieceDropper.DropObserver drobs)
Computes and effects the drop for the specified piece and any associated attached pieces. The supplied observer is notified of all drops.


drop

protected final void drop(DropBoard board,
                          int piece,
                          int xx,
                          int yy,
                          int ty,
                          PieceDropper.DropObserver drobs)
Helpy helper function.