Develop the classic game of Minesweeper
The following is a list of items (prioritized from most important to least important) we wish to see:
- Design and implement a documented RESTful API for the game (think of a mobile app for your API)
- When a cell with no adjacent mines is revealed, all adjacent squares will be revealed (and repeat)
- Ability to 'flag' a cell with a question mark or red flag
- Detect when game is over
- Persistence
- Ability to start a new game and preserve/resume the old ones
- Ability to select the game parameters: number of rows, columns, and mines
- Write specs (unit testing)
- I started working on the base game
- The attributes of the game are:
- rows
- columns
- mines
- status (to check if the game is new, incomplete or completed)
- board (which is going to hold the mines and data)
- I started with rspec and TDD, first the test, then the functionality
- The update and delete methods on games were not considered to not alter the games on the game REST inteface, it will be modified on another interface (such as moves or cells or something like that)
- Give up on the TDD (for now ๐ )
- Add a class to represent a cell with the following attributes
- mark: to represent a question mark or a flag
- value: the number of mines adjacent
- mine: to represent if the cell is a mine or not
- open: to represent if the cell has been revealed
- add two services to build the board randomly with the params passed
- I started working on the cells update.
- at the moment the user could flag, mark or open the cell.
- I'm thinking of making a service to handle all the logic of the update.
-
add the logic to reveal multiple cells, got an error with a recursive function but it was caused by the lifetime of the objects.
-
Still thinking on the logic for the win condition and the guard to not modify finished games.
- add the logic to check the win of a game
- add a new route to check the unfinished games
- add a new route to check the finished games
- add a constraint to the resource of game to match the new routes of finished and unfinished
GET /games
GET /games/:id
POST /games
- rows: number of rows that the board will have
- cols: number of columns that the board will have
- mines: number of mines in the board
GET /games/in-progress
GET /games/finished
PUT/PATCH /games/:id/cells/:row/:col
PUT/PATCH /games/:id/cells/:row/:col
- mark: the mark on the cell (flag, question)