How to play:
- The player enters a number between 1 to 8 for the row and a letter between A to H for the column.
- "X" indicates a hit on the board, and a message displaying "a hit!" is shown when a ship is hit.
- "*" indicates a miss on the board with a message displaying "missed!".
- The game is over whenever the player or computer hits all 5 ships or there are no more turns left and the game is over.
- Play against a computer.
- Random generation of ship placement for both the player and computer.
- The ships are hidden until hit, which is indicated by an "X" on the board.
- The board layout is 8x8 with 5 ships on each board and 30 turns.
- You can only enter numbers between 1 and 8 as a row, only letters between A and H as a column, and you cannot leave any input fields empty. If you do, a message will display telling you the input is not valid and to enter a valid one instead.
- Whenever the same combination of rows and columns is guessed multiple times, a message is displayed saying "You've guessed that already, try again!".
- A scoring system that updates each time the player or computer hits a ship.
- A result system that displays if it's a hit/miss, how many turns are left, who's the winner, or if it's a game over.
- Option to restart or quit when the game is over.
- The player will be able to pick the ship's location and see the placement on the board while playing.
- Different sizes of ships and boards, different difficulty modes (easy, medium, hard mode).
- Add some colors to the design.
- Multiplayer mode (player vs player).
- Ability to quit the game during an active session.
- Python.
I have manually done these tests:
- Passed the code through the PEP8 linter and confirmed that no problems or errors exist.
- Added error handling on all inputs, to make sure no invalid inputs can be given without a warning.
- Done tests in both my local terminal and the Code Institute Python terminal to ensure that each input and function works as it should. For example, when pressing enter or Q the game restarts or quits.
- PEP8
No errors.
- Sometimes it takes a second for it to load in everything at the start when you click the run program and it can seem like it has bugged out or something similar, not sure if it's something on my end or if it is the terminal itself. I mostly noticed it while using Dev Tools.
- Sometimes when asking for a row/column and you've put those in it will yet again ask for a row and column. It doesn't happen very often and most of the time it's just one time and then it will go back to working normally again. There were one or two times when it got stuck in an endless loop asking for a row/column, but it fixed itself whenever I clicked 'run program' or refreshed the webpage.
The project was deployed using Code Institute's Python Terminal on Heroku.
Steps:
- Clone or Fork this repository pp3-python.
- Create and/or log in to your account on Heroku.com
- Click on 'Create new app' from your dashboard.
- Set the buildbacks to Python and NodeJS (in that exact order).
- Link the repository to the Heroku app.
- Click 'Deploy'.
Fork the repository:
- Log in/sign up to GitHub.
- Go to the repository for this project pp3-python.
- Click the 'Fork' button in the top right corner.
Clone the repository:
- Log in/sign up to GitHub.
- Go to the repository for this project pp3-python.
- Click the code button, select which one you want to clone with (HTTPS, SSH, or GitHub CLI), and copy the link shown.
- Open the terminal in a code editor and change the current working directory to a location of your choice to use for the cloned directory.
- Type 'git clone' in the terminal, paste the link that you copied in step 3 and then press enter.
- Code Institute for the Python Essentials Template and Python Terminal.
- Followed Code Institute's 'Portfolio Project Scope' README Template that they made for their project called 'ULTIMATE Battleships'.
- Took some tips and inspiration from some of Knowledge Mavens tutorials, e.g. How to Code Battleship in Python - Single Player Game.