This is a simple Hangman game implemented in Ruby. The game allows users to play a new game or resume a previously saved game. The project is structured into two main classes: Hangman and Game.
Hangman is a classic word-guessing game where the player tries to guess a hidden word by suggesting letters within a certain number of attempts. This implementation allows users to save their progress and resume the game later.
- New Game: Start a new Hangman game.
- Load Game: Resume a previously saved game.
- Save Game: Save the current game state to a file.
- Word Selection: Randomly selects a word from a predefined list of words.
- Turns: The player has 9 turns to guess the word.
- User Input: Validates user input to ensure it is a single letter.
- Game State: Displays the current state of the word and the number of turns left.
To run this Hangman game, you need to have Ruby installed on your system. Follow these steps to get started:
-
Clone the Repository:
git clone https://github.com/Sandotech/hangman.git cd hangman -
Install Dependencies:
bundle install
-
Run the Game:
ruby lib/game.rb
When you run the game, you will be prompted to choose between starting a new game or loading a previous game.
- Choose option
2to start a new game. - Enter a name to save the game.
- Guess letters to uncover the hidden word.
- Type
SAVEto save the game and exit.
- Choose option
1to load a previous game. - Select the game you want to resume from the list.
- Continue guessing letters to uncover the hidden word.
- Turns: You have 9 turns to guess the word.
- Guessing: Enter a single letter to guess. If the letter is in the word, it will be revealed.
- Saving: Type
SAVEat any time to save the current game state and exit. - Winning: You win if you guess the word before running out of turns.
- Losing: You lose if you run out of turns without guessing the word.
- During gameplay, type
SAVEto save the current game state. - The game will be saved with the name you provided at the start of the game.
- When prompted, choose option
1to load a previous game. - Select the game you want to resume from the list.
- The game will be loaded, and you can continue from where you left off.
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Enjoy playing Hangman! If you have any questions or need further assistance, feel free to reach out.
Diego SantosBackend developer
