This project is mainly about practicing Test Driven Development by implementing the classic game 'Battleship'. Battleship is a strategy type guessing game for two players. It is played on ruled grids (paper or board) on which each player's fleet of warships are marked. The locations of the fleets are concealed from the other player. Players alternate turns calling "shots" at the other player's ships, and the objective of the game is to destroy the opposing player's fleet.
- Create ship, gameboard, and player factory functions where the only methods or properties that are used outside of these functions will be tested
- Gameboards should have functions that could place ships, receive attack and determine if a ship is hit or not, keep track of missed attacks, and report whether or not all the ships have sunk
- Computer player should know when a given move is legal or not
- The game loop should step through the game turn by turn using only methods from other objects
- Testing
- Factory functions
- IIFE
- DOM Drag and drop
- Modules
- A little bit of recursion
- OOP Principles
This project has taken a long time to complete because I've been busy with other things. But while making this game, I've observed myself trying to write my code efficiently. I've also tried to simplify functions that contain recurrent or complex methods. My biggest take away from this project is that I really try to make my code look better and follow the SOLID Principles. Although it is not perfect, I'm still proud of myself.
I can also relate to the articles and videos that I've watched prior this project that said TDD is overwhelming. I wasn't sure what to do or where to begin at first. Taking lots of time to think and analyze what I'm doing led me to the completion of this project.