diff --git a/src/java/com/threerings/puzzle/drop/client/DropBlockSprite.java b/src/java/com/threerings/puzzle/drop/client/DropBlockSprite.java
index 480dec68f..ca92a9bc1 100644
--- a/src/java/com/threerings/puzzle/drop/client/DropBlockSprite.java
+++ b/src/java/com/threerings/puzzle/drop/client/DropBlockSprite.java
@@ -1,5 +1,5 @@
//
-// $Id: DropBlockSprite.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
+// $Id: DropBlockSprite.java,v 1.2 2003/12/31 01:26:23 ray Exp $
package com.threerings.puzzle.drop.client;
@@ -160,6 +160,22 @@ public class DropBlockSprite extends DropSprite
buf.append(", ecol=").append(_ecol);
}
+ /**
+ * Can this sprite pop-up a row on a forgiving rotation?
+ */
+ public boolean canPopup ()
+ {
+ return (_popups > 0);
+ }
+
+ /**
+ * Called if we pop up to decrement the remaining popups we have.
+ */
+ public void didPopup ()
+ {
+ _popups--;
+ }
+
/**
* Re-calculates the external piece position and bounds of the drop
* block.
@@ -223,6 +239,10 @@ public class DropBlockSprite extends DropSprite
}
}
+ /** How many times this sprite can be popped-up a row in a forgiving
+ * rotation. */
+ protected byte _popups = 2;
+
/** The drop block bounds in board coordinates. */
protected Rectangle _dbounds = new Rectangle();
diff --git a/src/java/com/threerings/puzzle/drop/client/DropControllerDelegate.java b/src/java/com/threerings/puzzle/drop/client/DropControllerDelegate.java
index ad6914a12..5faef641e 100644
--- a/src/java/com/threerings/puzzle/drop/client/DropControllerDelegate.java
+++ b/src/java/com/threerings/puzzle/drop/client/DropControllerDelegate.java
@@ -1,5 +1,5 @@
//
-// $Id: DropControllerDelegate.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
+// $Id: DropControllerDelegate.java,v 1.2 2003/12/31 01:26:23 ray Exp $
package com.threerings.puzzle.drop.client;
@@ -374,7 +374,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// get the drop block position resulting from the rotation
int[] info = _dboard.getForgivingRotation(
rows, cols, _blocksprite.getOrientation(), dir,
- getRotationType(), pctdone);
+ getRotationType(), pctdone, _blocksprite.canPopup());
if (info != null) {
// Log.info("Found valid rotation " +
// "[orient=" + DirectionUtil.toShortString(info[0]) +
@@ -387,6 +387,10 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// place the block in its newly rotated location
_blocksprite.setBoardLocation(info[2], info[1]);
+ if (info[3] != 0) {
+ _blocksprite.didPopup();
+ }
+
// let derived classes do what they will
blockDidRotate(dir);
}
diff --git a/src/java/com/threerings/puzzle/drop/data/DropBoard.java b/src/java/com/threerings/puzzle/drop/data/DropBoard.java
index 42f92976c..c33ebf3ff 100644
--- a/src/java/com/threerings/puzzle/drop/data/DropBoard.java
+++ b/src/java/com/threerings/puzzle/drop/data/DropBoard.java
@@ -1,5 +1,5 @@
//
-// $Id: DropBoard.java,v 1.2 2003/12/31 00:03:14 ray Exp $
+// $Id: DropBoard.java,v 1.3 2003/12/31 01:26:23 ray Exp $
package com.threerings.puzzle.drop.data;
@@ -188,13 +188,16 @@ public abstract class DropBoard extends Board
/**
* Rotates the given block in the given direction and returns its
- * final state as (orient, col, row), where
+ * final state as (orient, col, row, popped), where
* orient is the final orientation of the drop block;
* col and row are the final column and row
* coordinates, respectively, of the central drop block piece.
+ * popped will be set to 1 if the piece was popped up, 0
+ * otherwise.
*/
public int[] getForgivingRotation (
- int[] rows, int[] cols, int orient, int dir, int rtype, float pctdone)
+ int[] rows, int[] cols, int orient, int dir, int rtype, float pctdone,
+ boolean canPopup)
{
int px = cols[0], py = rows[0];
int epx = cols[1], epy = rows[1];
@@ -241,28 +244,26 @@ public abstract class DropBoard extends Board
// ", orient=" + DirectionUtil.toShortString(orient) +
// ", owid=" + ORIENT_WIDTHS[oidx] +
// ", ohei=" + ORIENT_HEIGHTS[oidx] + "].");
- return new int[] { orient, px + cx, py };
+ return new int[] { orient, px + cx, py, 0 };
}
}
// if our piece is facing south and we're using radial
// rotation then we need to try popping the piece up a row to
// check for a fit
- /*
- if (rtype == RADIAL_ROTATION && orient == SOUTH) {
+ if (canPopup && rtype == RADIAL_ROTATION && orient == SOUTH) {
// check if our hypothetical new coordinates are empty
if (isBlockEmpty(ox, oy - 1,
ORIENT_WIDTHS[oidx], ORIENT_HEIGHTS[oidx])) {
-// Log.info("Popped-up block is empty [ox=" + ox +
-// ", oy=" + (oy - 1) + ", oidx=" + oidx +
-// ", orient=" + DirectionUtil.toShortString(orient) +
-// ", owid=" + ORIENT_WIDTHS[oidx] +
-// ", ohei=" + ORIENT_HEIGHTS[oidx] +
-// ", bhei=" + _bhei + "].");
- return new int[] { orient, px, py - 1 };
+ Log.info("Popped-up block is empty [ox=" + ox +
+ ", oy=" + (oy - 1) + ", oidx=" + oidx +
+ ", orient=" + DirectionUtil.toShortString(orient) +
+ ", owid=" + ORIENT_WIDTHS[oidx] +
+ ", ohei=" + ORIENT_HEIGHTS[oidx] +
+ ", bhei=" + _bhei + "].");
+ return new int[] { orient, px, py - 1, 1 };
}
}
- */
}
// this should never happen since even in the most tightly