-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (58 loc) · 2.08 KB
/
main.cpp
File metadata and controls
71 lines (58 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
This is the console executable, that makes use of the BullCow Class
THis acts as the view in a MVC patter and is responsible for all user interaction.
For game logic see the fBullCowGame class.
*/
#include <iostream>
#include "fBullCowGame.h"
using FText = std::string;
using int32 = int;
FText GetPlayerGuess();
bool AskToPlayAgain();
void ThankYouGoodBye();
void PlayGame();
int32 main() {
PlayGame();
return 0;
}
fBullCowGame Game;
void PlayGame() {
Game.PrintIntro();
Game.Reset();
//While game is not won and turns remaining, continue asking for guesses
while(!Game.IsGameWon() && Game.GetCurrentTry() <= Game.GetMaxTries()) {
Game.PrintCurrentStats();
FText RoundGuess = GetPlayerGuess();
fBullCowCount BullCowCount = Game.SubmitGuess(RoundGuess);
std::cout << "Bulls = " << BullCowCount.Bulls << std::endl;
std::cout << "Cows = " << BullCowCount.Cows << std::endl;
}
if (Game.PrintGameSummary() == true){
PlayGame();
};
}
FText GetPlayerGuess() {
FText Guess;
EGuessStatus GuessCheck = EGuessStatus::Invalid_Status;
do {
std::cout << "Enter Guess: \n";
std::getline(std::cin, Guess);
GuessCheck = Game.CheckGuessValid(Guess);
switch (GuessCheck) {
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << Game.GetHiddenWordLength() << " letter word, this isn't going well for you\n\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "You didn't enter an isogram.... RTFM brohiem, here you go... http://lmgtfy.com/?q=what+is+an+isogram\n\n";
break;
case EGuessStatus::Not_All_Lowercase:
std::cout << "Yea, this one is totally on me. This isn't python or go, make your guess all lower case isn't that easy, so do it for me for now...\n\n";
break;
default:
// assumes valid guess
continue;
}
std::cout << std::endl;
} while(GuessCheck != EGuessStatus::OK);
return Guess;
}