Commit ce3f0bb8 authored by Terence Martin's avatar Terence Martin

Include new states for round bookends

This includes new states for the beginning and ending of a round, so
that we can implement special logic to happen in those cases.
parent b9fdd5b2
......@@ -1859,40 +1859,46 @@ var nurdz;
* all possible known states so that it can act as a sentinel.
*/
GameState[GameState["NO_STATE"] = 0] = "NO_STATE";
/**
* This state is set when it's the start of a new round. This checks to
* see if the game is over or not, and either proceeds to generation of
* a new maze or goes to the end of the game state.
*/
GameState[GameState["BEGIN_ROUND"] = 1] = "BEGIN_ROUND";
/**
* This state is set while the maze is undergoing generation. The Maze
* entity doing the generation will inform the registered event listener
* when the generation is completed, at which point it will switch away
* from this state.
*/
GameState[GameState["MAZE_GENERATION"] = 1] = "MAZE_GENERATION";
GameState[GameState["MAZE_GENERATION"] = 2] = "MAZE_GENERATION";
/**
* We want it to be the human player's turn. In this state we check to
* see if the human (or computer) can take a turn. If yes, the
* appropriate player state is swapped to. Otherwise we skip to the
* state where we start removing gray bricks.
*/
GameState[GameState["CHECK_VALID_PLAY_PLAYER"] = 2] = "CHECK_VALID_PLAY_PLAYER";
GameState[GameState["CHECK_VALID_PLAY_PLAYER"] = 3] = "CHECK_VALID_PLAY_PLAYER";
/**
* We have determined that the player has at least one play to make, so
* they can take a turn now. In this state, the controls available to
* the player to make a move are enabled.
*/
GameState[GameState["PLAYER_TURN"] = 3] = "PLAYER_TURN";
GameState[GameState["PLAYER_TURN"] = 4] = "PLAYER_TURN";
/**
* We want it to be the computer player's turn. In this state we check
* to see if the computer (or human) can take a turn. If yes, the
* appropriate player state is swapped to. Otherwise we skip to the
* state where we start removing gray bricks.
*/
GameState[GameState["CHECK_VALID_PLAY_COMPUTER"] = 4] = "CHECK_VALID_PLAY_COMPUTER";
GameState[GameState["CHECK_VALID_PLAY_COMPUTER"] = 5] = "CHECK_VALID_PLAY_COMPUTER";
/**
* The computer is taking its turn now. This state encompasses the
* entirety of the computer taking it's turn, from selecting the move to
* arriving at the correct position and pushing the ball. The update()
* method in the Player entity is used to control this entire process.
*/
GameState[GameState["COMPUTER_TURN"] = 5] = "COMPUTER_TURN";
GameState[GameState["COMPUTER_TURN"] = 6] = "COMPUTER_TURN";
/**
* Either the human player or the AI has pushed a ball. This state
* remains in effect until the ball has finished moving, in which case
......@@ -1900,21 +1906,21 @@ var nurdz;
* to take their turn or to the state where we start the end of round
* proceedings. round.
*/
GameState[GameState["BALL_DROPPING"] = 6] = "BALL_DROPPING";
GameState[GameState["BALL_DROPPING"] = 7] = "BALL_DROPPING";
/**
* ALl of the possible plays have been made. In this state we are
* finding and removing all balls that can't possibly move any farther
* because they are not sitting on top of a gray brick that will vanish
* and allow them to fall.
*/
GameState[GameState["REMOVE_BLOCKED_BALLS"] = 7] = "REMOVE_BLOCKED_BALLS";
GameState[GameState["REMOVE_BLOCKED_BALLS"] = 8] = "REMOVE_BLOCKED_BALLS";
/**
* All of the possible plays have been made and all blocked ball have
* beem removed. In this state we are removing all of the gray bricks
* that are in the maze by vanishing them away. Once that is done we
* transition to the state where we start dropping the final balls.
*/
GameState[GameState["REMOVE_GRAY_BRICKS"] = 8] = "REMOVE_GRAY_BRICKS";
GameState[GameState["REMOVE_GRAY_BRICKS"] = 9] = "REMOVE_GRAY_BRICKS";
/**
* All of the gray bricks have been removed, so we are now in the
* process of finding all balls that can still drop and dropping them.
......@@ -1922,13 +1928,19 @@ var nurdz;
* we either cycle back to the generation state for the next round or to
* the game over state.
*/
GameState[GameState["FINAL_BALL_DROP"] = 9] = "FINAL_BALL_DROP";
GameState[GameState["FINAL_BALL_DROP"] = 10] = "FINAL_BALL_DROP";
/**
* We were dropping final balls, but we have determined that there are
* no more balls to drop. In this case we advance to the next round of
* the game.
*/
GameState[GameState["END_ROUND"] = 11] = "END_ROUND";
/**
* All of the gray bricks have been removed, all of the final ball drops
* have finished, and we have no more rounds to play; the game is just
* over now.
*/
GameState[GameState["GAME_OVER"] = 10] = "GAME_OVER";
GameState[GameState["GAME_OVER"] = 12] = "GAME_OVER";
})(GameState = game.GameState || (game.GameState = {}));
/**
* This class represents the state of the game in the current game. This is
......
......@@ -12,6 +12,13 @@ module nurdz.game
*/
NO_STATE,
/**
* This state is set when it's the start of a new round. This checks to
* see if the game is over or not, and either proceeds to generation of
* a new maze or goes to the end of the game state.
*/
BEGIN_ROUND,
/**
* This state is set while the maze is undergoing generation. The Maze
* entity doing the generation will inform the registered event listener
......@@ -85,6 +92,13 @@ module nurdz.game
*/
FINAL_BALL_DROP,
/**
* We were dropping final balls, but we have determined that there are
* no more balls to drop. In this case we advance to the next round of
* the game.
*/
END_ROUND,
/**
* All of the gray bricks have been removed, all of the final ball drops
* have finished, and we have no more rounds to play; the game is just
......
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