Skip to content

Iteration 5

Enan Ashaduzzaman edited this page Dec 2, 2019 · 35 revisions

Iteration 5 - Final Application

Features Assigned

As instructed in the documents, two features were attributed to each member of the team. Below is the task distribution:

Feature Number Feature Assigned Member
1 Enter Replay Mode Vanessa Ifrah
2 Step Forward Shuby Mao (Le-Li)
3 Step Backward Shuby Mao (Le-Li)
4 Jump to Start Position Enan Ashaduzzaman
5 Jump to Final Position Enan Ashaduzzaman
6 Identify if Game Drawn Andrew Ta
7 Identify if Game Won Vanessa Ifrah
8 Report Final Result Sacha Lévy
9 Resign Game Andrew Ta
10 Check if Path Exists Sacha Lévy
11 Save Game Mitchell Keeley
12 Load Game Mitchell Keeley

Implementation of the Controller Methods

Feature 1: Enter Replay Mode (Vanessa Ifrah)

  1. enterReplayMode() Sets the status of the game to Replay. When this feature is called, it will first check if the game can go into replay mode by calling isReplayPossible() (defined further down in the Query Methods section). The method will otherwise throw an exception.

  2. exitReplayMode() This feature allows a user to exit replay mode. The user may exit at any point during replay mode and will be brought back to the game, if still running.

When exiting from move X, for example, the user will reenter the game at the move X, ready to play move X+1. In other words, any subsequent moves to X that had already been made in the past iteration of the game are removed and the player plays new moves starting with move X+1. If the game was already terminated by a win or draw, it will notify the user that the game cannot be continued instead of reentering the game.

Feature 2: Step Forward (Le-Li Mao)
Primary Method:

  1. void StepForward() Perform a step forward in the replay mode. If the user is already in the last step, notify the user that the operation can not be done.

Helper Method:

  1. findPositionIndex() Find the index of the current position and return it to the caller.

Step Forward Operation

Feature 3: Step Backward (Le-Li Mao)
Primary Method:

  1. void StepBackward() Perform a step backward in the replay mode. If the user is already in the first step, notify the user that the operation can not be done.

Helper Method:

  1. findPositionIndex() Find the index of the current position and return it to the caller.

Step Backward Operation

Feature 4: Jump to Start Position (Enan Ashaduzzaman)

  1. jumpToStartPosition() Perform the jump to the start position within replay mode during a player's respective turn. The start position is considered to be the initial setup of the game. In order to perform this operation, the game needs to be in replay mode otherwise, it cannot be called.

Helper Method:

  1. isReplay() -check if the game is in replay mode

Jump to Start Position Operation

Feature 5: Jump to Final Position (Enan Ashaduzzaman)

  1. jumpToFinalPosition() Perform the jump to the final position within replay mode during a player's respective turn. The final position is considered to be the last move made during the game before replay mode was initiated. In order to perform this operation, the game needs to be in replay mode otherwise, it cannot be called.

Helper Method:

  1. isReplay() -check if the game is in replay mode

Jump to Final Position Operation

Feature 6: Identify if Game Drawn (Andrew Ta)

Primary method

  1. boolean identifyDraw() - Identify if a player repeats his or her move for the third time by checking the last 9 moves performed. This method will be called after a move is performed.

Helper method

  1. boolean checkMove(Move move1, Move move2) - Check if two moves have the same targeted tile or not.

Feature 7: Identify if Game Won (Vanessa Ifrah)

  1. identifyWin() Identifies a win by one of the players. A win is determined by the position of a pawn on the board. More specifically, a win is attributed to a player if their pawn reaches the opposite end of the board relative to their starting point.

Since the black and white pawns start at opposite ends of the board (i.e. white starts at the bottom of the board and black starts at the top end of the board), this feature will first check which player is currently moving its pawn and afterwards check if the pawn has reached the opposite end of the board relative to where it started (i.e. a win for white is when it reaches row 1 - any column - while a win for black is when it reaches row 9 - any column).

The method is called after every move made by the payers in the game and returns a boolean notifying the controller of a win, provided one of the players reached their goal.

Feature 8: Report Final Result (Sacha Levy) Feature dependent on game conclusions through identifying if game won/drawn, triggered by moving pawns to final positions. Throws a message to the dialog box indicating the outcome of the game.

Report final result

Feature 9: Resign Game (Andrew Ta) Primary method

  1. resignGame(String playerName) : finish the game and set game status according to the string playerName

Feature 10: Check if Path Exists (Sacha Levy) Primary method:

  1. hasPath() : check if both players has a path to their goal rows from their current positions, embedded in drop wall feature, blocking dropWall if illegal operation & throwing an error to the dialog box.

Helper methods:

  1. addWall() : add a wall to the matrix representation of the board
  2. checkMazeMap() : verify that from a given initial position, the given goal row is accessible on the map.

Check if Path Exists

Feature 11: Save Game (Mitchell Keeley)

Primary Method:

  1. boolean saveGame(String filename) - Save the current game as a file in the filesystem

Helper Methods:

  1. boolean checkIfFileExists(String filename) - Checks if file exists in the filesystem
  2. boolean userOverwritePrompt(String filename) - Prompt the user for permission to overwrite the existing file
  3. boolean saveGameToExistingFile(String filename) - Save game to an existing save file
  4. boolean saveGameToNewFile(String filename) - Save game to a newly created save file
  5. boolean saveCurrentGameAsFile(String filename) – Save the current game as a file

Save Game

Feature 12: Load Game (Mitchell Keeley)

Primary Method:

  1. boolean loadGame(String filename) - Load a new game from a file in the filesystem

Helper Methods:

  1. boolean checkIfLoadFileIsValidFile(String filename) - Checks if the load file is a valid file
  2. boolean getLoadGameDataFromFile(String filename) - Get the load game data from the specified file into the game
  3. boolean loadGameTryPawnMove(String position, PlayerPosition playerPos, PawnBehavior colorBehavior) - Using the move data from the load file, attempt the pawn move
  4. boolean loadGameTryWallMove(String position, Player player) - Using the data from the load game file, attempt the wall move

Load Game

Step Definitions (Gherkins Scenario Mappings)

Feature 1: Enter Replay Mode
Fully implemented and fully pass all step definitions.
Feature 2: Step Forward
Fully implemented and fully pass all step definitions.
Feature 3: Step Backward
Fully implemented and fully pass all step definitions.
Feature 4: Jump to Start Position
Fully implemented and fully pass all step definitions.
Feature 5: Jump to Final Position
Fully implemented and fully pass all step definitions.
Feature 6: Identify if Game Drawn
Fully implemented and fully pass all step definitions.
Feature 7: Identify if Game Won
Fully implemented and fully pass all step definitions.
Feature 8: Report Final Result
Fully implemented and fully pass all step definitions.
Feature 9: Resign Game
Fully implemented and fully pass all step definitions.
Feature 10: Check if Path Exists
Fully implemented and fully pass all step definitions.
Feature 11: Save Game
Fully implemented and fully pass all step definitions.
Feature 12: Load Game
Fully implemented and fully pass all step definitions.

Query Methods

  1. isReplay() - Check to see if the current game is in Replay Mode
  2. isReplayPossible() - Check to see if the current game can go into Replay Mode Le-Li Mao
  3. findPositionIndex() Find the index of the current position and return it to the caller.
  4. addWall(int[][] wallmap, WallMove wall) update the wall matrices based on the wall move.
  5. checkMazeMap(int goal_row, int[][] mazeMap, int i, int j) check if it is possible to reach the desired row given a wall matrices and starting coordinate i and j (row-1 and col-1 respectively). Returns a boolean of possible or not. Utilize breadth first search to quickly check for a path.

Bonus

  1. Professor mentioned that if teams handed in iteration 2 on Friday instead of the extended date of Sunday, they would be considered for the bonus. Our group ended up handing in the iteration by Friday night in hopes of being considered for the bonus.

  2. Step Forward bug discovered (issue #31) Issue1

  3. Jump To Final bug discovered (issue #29) Issue2

  4. Jump To Start bug discovered (issue #29) Issue3

  5. Step Forward bug discovered (issue #29) Issue4

  6. Jump To Final bug discovered (issue #29) Issue5