Play the game here.
This game is designed to test Python basic skills acquired in the Code Institute’s Full Stack developer course. This game is similar to a classic Battlefield game, built in to be played by a user trying to find one treasure in a map through the use of row and column instructions.
The user is greeted with a treasure chest image in ASCII graphic style, and the player are asked to enter a name.
After input a valid name (only letters from A-Z) a menu with three different map dimensions are presented, each one for a respective game level is displayed.
After chosen a size, the player is then invited to choose a location to begin their exploration. Depending on the level the player chose a 3x3, 5x5 or 9x9 map will be presented and then the player will be invited to choose a number between 0 and the maximum coordinate on the right of the map (2, 4 or 8).
Each round the user must enter a new coordinate with number to a row and a column subsequently.
If the coordinates are outside the map dimensions or has already been chosen in a previous turn, the user will not lose any attempt but must enter new valid coordinates.
If chooses a location where the treasure is not, will have a reduced chance of his total attempts by one, until has no more chance and loses the game.
If the player does not find the treasure before the attempts are over, will receive citation and an end game message, followed for a question for play again or quit.
If the player finds the treasure before the attempts are over, will receive citation and victory message, followed for a question for play again or quit.
A title screen with a graphic design to introduce users to the game.
A short welcome greeting is presented. Then the player is invited to enter a valid name.
The player must choose between 3 predetermined levels of difficulty. Being:
Here, only numbers 1, 2 and 3 are accepted as inputs.
In this area the game itself develops. A grid composed of a matrix cell where only a certain coordinate contains the treasure.
With each new game, this treasure is placed at random for the user to try to find it, so the replay factor makes the game more inviting.
All the player’s possibilities are shown on the map and each turn the user must choose a number between 0 and the right border (maximum size of the matrix -1) for both the row and the column.
The chosen coordinates will be are marked on the map with an X. In these places there were no treasures, so they should not be re-chosen. A new turn will again start asking the player what the new coordinates will be and the player will have one less try to find the treasure.
If the location has the treasure hidden in it, then the user has discovered it and won the game.
If the coordinates are off the map, that is, with numbers that are not between 0 and maximum range of the chosen level, for both rows and columns, an error message will be displayed on the screen but no attempt will be lost by the user, which will keep their chances. Same as the previous turn.
If the coordinates are equal to some that had been previously chosen by the user, an error message will be displayed on the screen and, in the same way as the previous one, no penalty will occur in relation to the user’s attempts.
If the player enters any value that is not valid, this being an empty space, non-integer numbers, negatives, fractions, letters, signs or special characters, an error will be displayed, the player will be invited to choose his coordinates again, this time using only numbers valid for chosen game level(size), without losing a previous attempt.
After spending all available attempts, the player did not find the treasure and so the game comes to an end with the player’s defeat.
Note that all the player’s attempts have been recorded on the board with “X”, while the location of the treasure is shown with the letter “T”. This location is also written in the game.
When within his chances the player manages to find the exact location of the treasure a win message will be displeyd, and the location of the treasure is also displayed with the letter “T” on the board.
When the game comes to an end, in both winning and losing situations, the player will be able to choose whether to continue playing.
If you accept, you will choose the desired difficulty for your new game again and then the loop of a new game starts keeping the player’s name, however, the treasure will have its location randomized again.
If the player does not want to continue playing at the end of a game, he will find a thank you message for having played and will be invited to come back soon.
Python syntax checker from Extends Class and Python style guide checker from flake8 and pycodestyle 2.9.1 were used to test, verify and validate code written in python.
No major errors were returned from both, except “E501 line too long” caused for some text phrases inside the game, and “W605 invalid escape sequence”, “W291 trailing whitespace”, “W293 blank line contains whitespace” caused by game graphics using ASCII art style.
Code Institute PEP8 Checker - “CI Python Linter” also used and return the same errors.
Here are the tests that we have conducted to ensure that the program is working correctly:
Description: Enter a valid name and a valid level choice.
Steps:
When prompted, enter a non-empty name that contains letters from A to Z and is at least one character long. When prompted, enter a valid level choice (1-3).
Expected Result: The program should start the game with the given name and level.
Description: Enter an invalid name.
Steps:
When prompted, enter a name that contains non-alphabetic characters or is empty.
Expected Result: The program should display an error message and prompt the user to enter a valid name.
Description: Enter an invalid level choice.
Steps:
When prompted, enter a level choice that is not between 1-3.
Expected Result: The program should display an error message and prompt the user to enter a valid level choice.
Description: Restart the game without entering the name again.
Steps:
Start the game with a valid name and level choice. When prompted to restart the game, enter ‘Y’ to restart the game. When prompted, enter a valid level choice (1-3).
Expected Result: The program should restart the game with the same name and the new level choice.
Description: Enter an invalid restart choice.
Steps:
Start the game with a valid name and level choice. When prompted to restart the game, enter an invalid choice that is not ‘Y’ or ‘N’.
Expected Result: The program should display an error message and prompt the user to enter a valid restart choice.
Description: Win the game by finding the treasure.
Steps:
Start the game with a valid name and level choice. Keep playing the game until the treasure is found.
Expected Result: The program should display a winning message and prompt the user to play again or quit.
Description: Lose the game by running out of moves.
Steps:
Start the game with a valid name and level choice. Keep playing the game until all moves are used up.
Expected Result: The program should display a losing message and prompt the user to play again or quit.
This game was deployed using Code Institute’s mock terminal for Heroku.
The link to the deployed game at Heroku is: https://git.heroku.com/iurjoh-treasure-hunt.git
The full file was also deployed in my GitHub repository. The steps are as follows:
The link to the deployed website at GitHub is: https://iurjoh.github.io/Treasure-Hunt/
Here will be the sites that helped me find everything I needed to develop my work, including research and material sources.
Sites such as: