Commit cacdab8a authored by Terence Martin's avatar Terence Martin

Implement ball removal state

This hooks into the previously created method and will continuously
try to remove blocked balls from the maze until the method tells it
that there are no further balls to remove and all that were removed
are now done with.

We skip to this state when all plays are exhausted and then to the
remove gray bricks state once this is completed.
parent 416c2951
......@@ -4614,6 +4614,12 @@ var nurdz;
(function (nurdz) {
var game;
(function (game) {
/**
* When we are in the state that we're removing blocked balls from the maze,
* this is the delay (in ticks) for telling the next ball when it should
* start to vanish.
*/
var ROUND_BALL_VANISH_TIME = 3;
/**
* When we are in the state that we're removing gray bricks from the maze,
* this is the delay (in ticks) for telling the next brick when it should
......@@ -5128,7 +5134,7 @@ var nurdz;
if (this._maze.contents.hasPlayableComputerBall())
this.state = game.GameState.COMPUTER_TURN;
else
this.state = game.GameState.REMOVE_GRAY_BRICKS;
this.state = game.GameState.REMOVE_BLOCKED_BALLS;
}
break;
// It is becoming the computer's turn; check to see if there is
......@@ -5144,6 +5150,18 @@ var nurdz;
if (this._maze.contents.hasPlayableHumanBall())
this.state = game.GameState.PLAYER_TURN;
else
this.state = game.GameState.REMOVE_BLOCKED_BALLS;
}
break;
// When we are in the remove blocked balls state, use the state
// timer to remove a blocked ball every so often, until we
// determine that there are none left.
case game.GameState.REMOVE_BLOCKED_BALLS:
if (this._state.timerTrigger(ROUND_BALL_VANISH_TIME)) {
// Try to remove a ball; this returns false when there
// are no more balls to remove AND all balls we were
// waiting for are now gone.
if (this._maze.removeNextBlockedBall() == false)
this.state = game.GameState.REMOVE_GRAY_BRICKS;
}
break;
......
module nurdz.game
{
/**
* When we are in the state that we're removing blocked balls from the maze,
* this is the delay (in ticks) for telling the next ball when it should
* start to vanish.
*/
const ROUND_BALL_VANISH_TIME = 3;
/**
* When we are in the state that we're removing gray bricks from the maze,
* this is the delay (in ticks) for telling the next brick when it should
......@@ -632,7 +639,7 @@ module nurdz.game
if (this._maze.contents.hasPlayableComputerBall ())
this.state = GameState.COMPUTER_TURN;
else
this.state = GameState.REMOVE_GRAY_BRICKS;
this.state = GameState.REMOVE_BLOCKED_BALLS;
}
break;
......@@ -650,6 +657,20 @@ module nurdz.game
if (this._maze.contents.hasPlayableHumanBall ())
this.state = GameState.PLAYER_TURN;
else
this.state = GameState.REMOVE_BLOCKED_BALLS;
}
break;
// When we are in the remove blocked balls state, use the state
// timer to remove a blocked ball every so often, until we
// determine that there are none left.
case GameState.REMOVE_BLOCKED_BALLS:
if (this._state.timerTrigger (ROUND_BALL_VANISH_TIME))
{
// Try to remove a ball; this returns false when there
// are no more balls to remove AND all balls we were
// waiting for are now gone.
if (this._maze.removeNextBlockedBall () == false)
this.state = GameState.REMOVE_GRAY_BRICKS;
}
break;
......
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