summaryrefslogtreecommitdiffstats
path: root/labb5/src/boggleplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'labb5/src/boggleplay.cpp')
-rwxr-xr-xlabb5/src/boggleplay.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/labb5/src/boggleplay.cpp b/labb5/src/boggleplay.cpp
index 914443b..da03d93 100755
--- a/labb5/src/boggleplay.cpp
+++ b/labb5/src/boggleplay.cpp
@@ -36,14 +36,11 @@ void playOneGame(Boggle& boggle) {
} else {
boggle.shuffle();
}
- boggle.find_all_words();
- cout << boggle.debug_words() << endl;
-
- std::cout << "It's your turn!" << std::endl;
- cout << boggle.board_to_string() << endl;
string user_input;
while (true) {
- cout << "Your words (" << boggle.get_user_words_size() << "):" << endl;
+ std::cout << "It's your turn!" << std::endl;
+ cout << boggle.board_to_string() << endl;
+ cout << "Your words (" << boggle.get_user_words_size() << "): " << endl;
cout << boggle.user_words_to_string() << endl;
cout << "Your score: " << boggle.get_user_score() << endl;
cout << "Type a word (or press Enter to end your turn) ";
@@ -51,7 +48,7 @@ void playOneGame(Boggle& boggle) {
if (user_input == "") {
break;
}
- if (!boggle.word_is_valid(user_input)) {
+ if (!boggle.find_single_word(user_input)) {
cout << "Your word is invalid" << endl;
} else if (!boggle.word_is_unplayed(user_input)) {
cout << "Your word has already been played!" << endl;
@@ -62,7 +59,16 @@ void playOneGame(Boggle& boggle) {
boggle.add_user_word(user_input);
}
}
-
+ cout << "It's my turn!" << endl;
+ boggle.do_computer_turn();
+ cout << "My words (" << boggle.get_computer_words_size() << "): " << endl;
+ cout << boggle.computer_words_to_string() << endl;
+ cout << "My score: " << boggle.get_computer_score() << endl;
+ if (boggle.get_computer_score() > boggle.get_user_score()) {
+ cout << "Ha ha ha, I destroyed you. Better luck next time, puny human!" << endl;
+ } else {
+ cout << "WOW, you defeated me! Congratulations!" << endl;
+ }
}
/*