Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odilson-dev/battleship
Battleship game implemented in JavaScript using Test Driven Development (TDD) principles
https://github.com/odilson-dev/battleship
battleship bundler html-css-javascript jest-tests test-driven-development webpack
Last synced: 2 days ago
JSON representation
Battleship game implemented in JavaScript using Test Driven Development (TDD) principles
- Host: GitHub
- URL: https://github.com/odilson-dev/battleship
- Owner: odilson-dev
- Created: 2024-03-27T17:24:09.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-11T20:28:44.000Z (6 months ago)
- Last Synced: 2024-05-17T15:26:40.410Z (6 months ago)
- Topics: battleship, bundler, html-css-javascript, jest-tests, test-driven-development, webpack
- Language: JavaScript
- Homepage: https://odilson-dev.github.io/battleship/
- Size: 3.38 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Battleship Game
The goal of this project is to implement the classic game Battleship using Test Driven Development (TDD) principles.
![Battleship Game](/images/battleship.png)
## Introduction
Battleship is a classic two-player guessing game where each player attempts to sink the other player's fleet of ships by guessing the coordinates of the ships on a grid.
## Assignment Overview
The assignment involved creating several classes and functionalities:
1. **Ship Class/Factory**: A class or factory function to represent ships, including their length, hits, and whether they've been sunk.
2. **Gameboard Class/Factory**: A class or factory function to represent the gameboard, allowing the placement of ships and tracking of hits and misses.
3. **Player**: Players can take turns attacking the enemy gameboard. The game is played against the computer, which makes random plays.
4. **Main Game Loop and DOM Interaction**: Implementing the main game loop and creating a module for DOM interaction to display the game boards and take user input for attacking.
5. **End Game Condition**: Implementing conditions for the game to end once one player's ships have all been sunk.## Project Structure
The project consists of the following files:
- `Ship.js`: Contains the Ship class or factory function.
- `Gameboard.js`: Contains the Gameboard class or factory function.
- `Player.js`: Contains the Player class.
- `index.js`: Implements the main game loop and DOM interaction.
- `style.css`: Stylesheet for the game.
- `index.html`: HTML file to render the game.## How to Play
1. Open the `index.html` file in your browser to start the game.
2. Follow the on-screen instructions to place your ships and take turns attacking the opponent's gameboard.
3. The game ends when one player's ships have all been sunk.## What I've Learned
- Test Driven Development (TDD): Practiced writing tests before implementing functionality, ensuring that code meets requirements and remains maintainable.
- Object-Oriented Programming (OOP): Implemented classes and factory functions to create modular and reusable code.
- DOM Manipulation: Interacted with the DOM to render game elements and handle user input.
- Game Design: Designed game mechanics and logic to create an interactive Battleship game.## Conclusion
This project has been an exciting journey into the world of web development and software engineering. Through implementing the Battleship game with Test Driven Development (TDD) principles, I've gained valuable experience and learned important concepts, including:
- Applying TDD practices to ensure code quality and reliability.
- Designing and implementing classes and factories for managing game components.
- Utilizing JavaScript to create game logic and handle player interactions.
- Incorporating DOM manipulation for user interface interactions.
- Enhancing my understanding of software design principles and best practices.I'm proud of the progress I've made and the skills I've developed throughout this project. Building a complete Battleship game from scratch has been both challenging and rewarding, and I look forward to applying what I've learned to future projects.
Thank you for joining me on this journey!
Enjoy playing Battleship!