Commit b7594275 authored by Terence Martin's avatar Terence Martin

Fix bugs in blocked ball removal

This code went through several iterations, and so some things were not
in the correct order (e.g. null test AFTER other tests).

There was also an issue where a vanished ball would trigger the  ball
drop complete method and then throw an error because there is no
dropped ball, which I have currently patched away but this needs to be
handled better.
parent cacdab8a
......@@ -4325,13 +4325,13 @@ var nurdz;
// for hiding a ball during this call are that it is not
// already hidden (not already selected) and:
//
// 1) The cell below is an arrow
// 2) The cell below is a blank space (has to be a ball
// 1) The cell below is a blank space (has to be a ball
// that we previously vanished with a call like this)
// 3) What is below is a ball that is hidden (will soon
// become #2, just not there yet)
if (below.name == "arrow" ||
below == null ||
// 2) What is below is a ball that is hidden (will soon
// become #1, just not there yet)
// 3) The cell below is an arrow
if (below == null ||
below.name == "arrow" ||
(below.name == "ball" && below.isHidden == true)) {
cell.vanish();
return true;
......@@ -4438,7 +4438,7 @@ var nurdz;
this._ballMoveFinalized = false;
// If there is a listener, tell it that this ball has stopped
// moving now.
if (this._listener != null)
if (this._listener != null && this._lastDroppedBall != null)
this._listener.ballDropComplete(this._lastDroppedBall, this._lastDroppedBall.mapPosition.y == game.MAZE_HEIGHT - 2);
// Done with the value now.
this._lastDroppedBall = null;
......
......@@ -919,13 +919,13 @@ module nurdz.game
// for hiding a ball during this call are that it is not
// already hidden (not already selected) and:
//
// 1) The cell below is an arrow
// 2) The cell below is a blank space (has to be a ball
// 1) The cell below is a blank space (has to be a ball
// that we previously vanished with a call like this)
// 3) What is below is a ball that is hidden (will soon
// become #2, just not there yet)
if (below.name == "arrow" ||
below == null ||
// 2) What is below is a ball that is hidden (will soon
// become #1, just not there yet)
// 3) The cell below is an arrow
if (below == null ||
below.name == "arrow" ||
(below.name == "ball" && (<Ball>below).isHidden == true))
{
cell.vanish ();
......@@ -1052,7 +1052,7 @@ module nurdz.game
// If there is a listener, tell it that this ball has stopped
// moving now.
if (this._listener != null)
if (this._listener != null && this._lastDroppedBall != null)
this._listener.ballDropComplete (this._lastDroppedBall,
this._lastDroppedBall.mapPosition.y == MAZE_HEIGHT - 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment