An interactive, two player game of Battleship. The purpose of this project is to practice Test Driven Development (TDD) and tie together the concepts learned in the JavaScript module of The Odin Project. This is the capstone project of The Odin Project's JavaScript course.
Project description can be found here.
Live demo available here
- Singleplayer mode
- Multiplayer mode
- Manual ship placement
- Responsive design with mobile support
- HTML5
- CSS3
- JavaScript ES6
- Jest
- webpack
- Babel
- ESLint
- Prettier
This project helped to reinforce the following skills:
- Test Driven Development (TDD) with Jest
- ESLint integration
- Prettier integration
- Babel integration
- webpack
- JavaScript modules
- DOM manipulation
- CSS styling
This project could be improved with:
- Single player difficulty modes
- Drag and drop feature to place ships
- Ship icons to indicate ship placement instead of tile background color
- Animations or transitions for hit & miss attacks
- ESLint and prettier config did not seem to be working together. After much time trying to debug, restarting VSCode seemed to resolve the issue.
-
This resource was helpful for setting up jest and configuring
npm run watch -
This resource was helpful when running into node version errors while setting up jest.
-
This resource was helpful for setting up webpack for both development as well as production.
-
This resource was helpful when my node version kept resetting.
-
While setting up ESLint and Prettier with VSCode, I referenced this resource in addition to the docs.
-
The top answer of this thread seemed to resolve some ESLint errors that I was getting.
-
This resource is helpful when deploying to GitHub Pages.
-
This discussion seemed informativve when choosing between class and factory.
-
This codepen is very useful for assigning colors to SVG icons.
-
SVG Repo for icons
-
Jest setup
sudo apt install npmnvm install 18.18.0nvm use 18.18.0nvm alias default v18.18.0npm init, but maybe should have usednpm init jest@latestnpm install --save-dev jestnpm install --save-dev babel-jest @babel/core @babel/preset-envnpm install --save-dev @babel/preset-envnpm testornpm run watch:jestto run tests
-
Webpack setup
npm install webpack webpack-cli --save-devnpm install --save lodashnpm install --save-dev style-loader css-loadernpm install --save-dev html-webpack-pluginnpm install --save-dev webpack-dev-servernpx webpackornpm run build:devto bundle in development modenpm run build:prodto bundle in production modenpm run watch:webpackto recompile on savenpm run start:webpackto recompile on save and refresh page- source-maps may not be configured correctly when using this option
-
ESLint & Prettier setup
- I don't think there is a difference between these:
npm init @eslint/config@latest(ESLint docs)npm install eslint --save-dev&./node_modules/.bin/eslint --init(Digital Ocean Article)
npm install --save-dev eslint-config-prettiernpm install prettier -D --save-exactnode --eval "fs.writeFileSync('.prettierrc','{}\n')"^C
- I don't think there is a difference between these:
-
Deployment
npm run deploy
- Clone this repository to your desktop.
- Navigate to the top level of the directory by running
cd naval-warfare. - Run
npm installto install the required dependencies. - Open
dist/index.htmlin your browser. - Run
npm run watch:webpackto update thedistfolder on save - Refresh page after saving to see changes











