Rewriting a Minesweeper - Part 4
Welcome to the part 4 of rewriting Minesweeper game. This time I haven't added a lot of features. Just cleaned up some code and fixed minor and rare bugs. Here is the list of things I have done so far with the codebase.
- First and foremost, rewrote the logic to get the list of surrounding mines for a given tile. More details can be found on the separate post. tl; dr; Just compressed a method and replaced hardcoded logic with more elegant and clean solution
- Fixed constraints which were breaking every time grid was re-created with different grid size
- Restructured
GameHomePageViewController
to pass the relatedViewModel
during initialization phase - Added app icons
5. Moved tile specific code into MineButton
class
6. Replaced hard-coded values with enum
constants
7. Added support to reset the game with same or different grid size
Here's the final showdown of code while I am busy playing it,
This is it for now. Next time I will move on to write unit tests as game seems to be in better and stable state now. It's kind of surprising to see how in the beginning I thought game was already in the stable position until I started playing it a lot and realized there were definitely several kinks needed to iron out