Commit ef9e9917 authored by Terence Martin's avatar Terence Martin

Fix blocked player playing ball bug

This is the bug where the player can try to push the ball while its
blocked and it still works. This would get things all out of sync
and mess everything up.
parent 517aaf44
......@@ -4038,7 +4038,8 @@ var nurdz;
* column in the maze, if possible.
*
* The ball can only be pushed if the cell in the maze at that position
* is not empty, is a ball, and there is not already a ball dropping.
* is not empty, is a ball, is not immediately blocked from moving, and
* there is not already a ball dropping.
*
* The return value tells you if the drop started or not.
*
......@@ -4049,9 +4050,14 @@ var nurdz;
*/
Maze.prototype.pushBall = function (column) {
// Try to get the entity in the first row of the given column. If
// it exists and it is a ball, push it.
// it exists and it is a ball, we might want to push it.
var entity = this._contents.getCellAt(column, 0);
if (entity != null && entity.name == "ball" && this._droppingBall == null) {
// If the cell below the ball is blocked, this ball cannot be
// pushed, in which case we should leave without pushing the
// ball.
if (this._contents.getBlockingCellAt(column, 1, false) != null)
return false;
// Drop it and leave.
this.dropBall(entity, NORMAL_DROP_SPEED, false);
return true;
......
......@@ -463,7 +463,8 @@ module nurdz.game
* column in the maze, if possible.
*
* The ball can only be pushed if the cell in the maze at that position
* is not empty, is a ball, and there is not already a ball dropping.
* is not empty, is a ball, is not immediately blocked from moving, and
* there is not already a ball dropping.
*
* The return value tells you if the drop started or not.
*
......@@ -475,12 +476,18 @@ module nurdz.game
pushBall (column : number) : boolean
{
// Try to get the entity in the first row of the given column. If
// it exists and it is a ball, push it.
let entity = this._contents.getCellAt (column, 0);
// it exists and it is a ball, we might want to push it.
let entity = <Ball> this._contents.getCellAt (column, 0);
if (entity != null && entity.name == "ball" && this._droppingBall == null)
{
// If the cell below the ball is blocked, this ball cannot be
// pushed, in which case we should leave without pushing the
// ball.
if (this._contents.getBlockingCellAt (column, 1, false) != null)
return false;
// Drop it and leave.
this.dropBall (<Ball> entity, NORMAL_DROP_SPEED, false);
this.dropBall (entity, NORMAL_DROP_SPEED, false);
return true;
}
......
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