Skip to content

Commit

Permalink
Added a quit option and CI, resolves ChicoState#1, resolves ChicoState#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Munoz committed Feb 21, 2022
1 parent 3c4d001 commit b464712
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Wordler

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Compile C++ 2017
run: g++ main.cpp -std=c++17 -o wordler
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ Then play the game:
./wordler
```

The game will randomly-select a 5-letter word and you have unlimited guesses to get the word right. Each time you guess, if you have a letter that matches the same location as it is in the secret word, it will be revealed to you. However, any letter that does *not* match the secret word's letter at the same location will be displayed as `_`. Good luck!
The game will randomly-select a 5-letter word and you have unlimited guesses to get the word right. Each time you guess, if you have a letter that matches the same location as it is in the secret word, it will be revealed to you. However, any letter that does *not* match the secret word's letter at the same location will be displayed as `_`. Good luck!

To quit the game, simple type `quit` in the command line.
10 changes: 10 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int main(){
std::string hint;
std::string secret;
int guesses = 0;
bool quit = false;

secret = word_list.select_word();
// REVEAL ANSWER: std::cout << secret << std::endl;
Expand All @@ -24,8 +25,17 @@ int main(){
do{
do{
std::cin >> guess;
if (guess == "quit" || guess == "QUIT") {
quit = true;
break;
}
}while( guess.length() != 5 );

if (quit) {
std::cout << "You have quit the game. Have a good day!\n";
break;
}

// capitalize guess for easy comparisons
for(int i=0; i<guess.length(); i++){
guess[i] = toupper(guess[i]);
Expand Down
Binary file added wordler
Binary file not shown.

0 comments on commit b464712

Please sign in to comment.