Skip to content

Iteration 4

Enan Ashaduzzaman edited this page Nov 17, 2019 · 28 revisions

Iteration 4 - State Machines

Implementation of the Controller Methods

Feature 1: Start a New Game (Vanessa Ifrah)

  1. createGame() creates a Quoridor game and sets the game status to "Initializing"
  2. setGameToReady() sets the game status to "ReadyToStart"
  3. setGameToRun() sets the game status to "Running" and starts the clock

Start a New Game Page

Feature 2: Provide or Select User Name (Vanessa Ifrah)

  1. setUser(String name, String color) sets the player's name according to their color

Only one method was implemented to set the usernames instead of creating two adjacent methods createUser and selectUser. This was a design decision that moved the "creating vs. selecting" logic to the GUI in the ProvideSelectUserName page specifically. In this way, the different warnings and error messages are handled by the GUI.

Helper methods:

  • checkNameList(String name) checks if the name already exists - i.e. duplicate name - and returns a boolean
  • warnUser(String name) calls checkNameList(,) to decide if the user should be warned

Provide or Select a User Name Page

Feature 3: Set Total Thinking Time (Andrew Ta)

  1. setThinkingTime(Time thinkingTime, String playerName) Given a Time object and a String of player name, this method searches for that player and set its remaining thinking time to the Time object.

Helper Method:

  1. getPlayerByName(String playerName) Given a player name, this method will return the player object associated with that name.

Demo:

  1. Set remaining time for both players:

  2. Show error if input time is invalid:

Feature 4: Initialize Board (Andrew Ta)

  1. initializeBoard() This method will create a new board with 81 tiles for the current game. Then, 10 walls are created for each player, and they will be put on each player's stock. Two players, black and white, will then be put on their initial positions on the board. Finally, white player is set to move first.

Demo: 3. Initialize the board and start white player's clock:

Feature 5: Rotate Wall (Enan Ashaduzzaman)

  1. rotateWall() Perform the rotation of a selected wall during a player's turn. When this feature is called, the feature will first check if the player has an active wall on the board. If so, the feature can be implemented. If the wall is horizontal before the feature is performed, then the wall will become vertical after the feature is called. The vice versa of the previous statement is also true.

Helper Method:

  1. isRunning() -check if the game is running

Rotate Wall Operation

Feature 6: Grab Wall (Enan Ashaduzzaman)

  1. grabWall() Perform the grabbing of a wall from the wall stock of the respective player who calls this feature. The feature will first check if the wall stock if empty. If it is empty, it will throw a message to the user indicating this scenario. The feature then checks if there is already an active wall on the board. If there is already an active wall on the board, the user should not be able to grab another wall. If both of the previous scenarios pass, the feature will grab a wall from the respective player's wall stock and place it on the board game.

Grab Wall Operation

Helper Method:

  1. isRunning() - check if the game is running

Feature 7: Move Wall (Le-Li Mao)

Primary Method:

  1. moveWall(TOWall.Direction side) Perform a move on the currently selected wall toward a direction (given by variable side)

Helper Method:

  1. isRunning() -check if the game is running
  2. isWallPositionValid(int row, int col) -Check if a given row and col for a wall is valid

Move Wall Operation

Feature 8: Drop Wall (Le-Li Mao)

Primary Method:

  1. dropWall() -Perform a drop wall Operation that drops the currently held wall
  2. validatePosition() -(Made by Sacha) Used to validate position and prevent the invalid wall from being dropped.

Helper Method:

  1. clonePosition(GamePosition oldPosition) Create a copy of the given position object.
  2. clonePlayerPosition(PlayerPosition playerPos) Create a copy of the given PlayerPosition object.
  3. isRunning() - check if the game is running
  4. isWhitePlayer() - check who if the current player to move is white

Drop Wall Operation

Feature 9: Save Position (Mitchell Keeley)

Primary Method:

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

Helper Method:

  1. _ writeToNewFile(String filename)_ - A method to create and write to a new save file
  2. _ writeToExistingFile(String filename)_ - A method to write to an existing save file
  3. _ userOverwritePrompt(String filename)_ - A method to prompt the user for permission to overwrite the existing file
  4. _ saveCurrentGamePositionAsFile(String filename)_ - A method to save the current GamePosition as a file

Save Position

Feature 10: Load Position (Mitchell Keeley)

Primary Method:

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

Helper Method:

  1. _ checkLoadFileIsValid(String filename)_ - A method to check if the load file is a valid file
  2. _ loadMoveDataFromFile(String loadFile) _ - A method to load the game data from the specified file into the game

Load Position

Feature 11: Validate Position (Sacha Lévy) Primary Method:

  1. validatePosition() - Checks the board for any invalid wall positions, then if game has a wall move candidate check if its validity otherwise check validity of player position.

Helper Method:

  1. doWallsOverlap() - full check of walls on board (both black and white), looking for overlapping walls
  2. _isWallCandidateOverlapping() - checking if the wall is overlapping with any other on board
  3. isPlayerPositionValid() - check if the player position is valid (on board)
  4. isPlayerOverlapping() - check if the players positions overlap

Vertically Overlapping Walls

Horizontally Overlapping Walls

Overlapping Walls

Feature 12: Switch Player (Sacha Lévy) Primary Method:

  1. SwitchPlayer() - Set the current player to be the next Player of the current next player and the next player to become the current player.

Switch Player GUI Notification

Step Definitions (Gherkins Scenario Mappings)

Feature 1: Start a New Game
Fully implemented and fully pass all step definitions.
Feature 2: Provide or Select User Name
Fully implemented and fully pass all step definitions.
Feature 3: Set Total Thinking Time
Fully implemented and fully pass all step definitions.
Feature 4: Initialize Board
Fully implemented and fully pass all step definitions.
Feature 5: Rotate Wall
Fully implemented and fully pass all step definitions.
Feature 6: Grab Wall
Fully implemented and fully pass all step definitions.
Feature 7: Move Wall
Fully implemented and fully pass all step definitions.
Feature 8: Drop Wall
Fully implemented and fully pass all step definitions.
Feature 9: Save Position
Fully implemented and fully pass all step definitions.
Feature 10: Load Position
Fully implemented and fully pass all step definitions. Feature 11: Validate Position
Fully implemented and fully pass all step definitions. Feature 12: Switch Player
Fully implemented and fully pass all step definitions.

Transfer Objects

TOGame

  • Time playerOneTime;
  • Time playerTwoTime;
  • playerOne;
  • playerTwo;
  • playerToMove;

TOWall

  • enum Direction {Horizontal,Vertical};
  • enum Side {Up,Down,Left,Right};
  • Integer id;
  • Integer row;
  • Integer col;
  • Direction dir;

TOPlayer

  • enum Color {White,Black};
  • Integer row;
  • Integer col;
  • Color color;

Query Methods

Le-Li Mao

  1. getCurrentPlayerName() - Get the name of the current player to notify the user it is their turn after drop wall
  2. getWhiteWallInStock() - Return the number of walls in stock for the white player
  3. getBlackWallInStock() - Return the number of walls in stock for the black player
  4. getWhiteWallOnBoard() - Return a list of wall transfer objects on the board belonging to the white player
  5. getBlackWallOnBoard() - Return a list of wall transfer objects on the board belonging to a black player
  6. getWallInHand() - Return the Wall transfer object of the current wall candidate
  7. getPlayers() - Return a list of transfer object player in the current game
  8. convertWall(Wall aWall) - Convert a Wall object to a TOWall object

Mitchell Keeley

  1. tileToString(Tile tile) - Translate a tile into a save compatible string
  2. directionToString(Direction direction) - Translate a Direction into a save compatible string
  3. charToDirection(char letter) - Translate a character into the corresponding Direction
Clone this wiki locally