diff options
| author | Aiden Woodruff <aiden@aidenw.net> | 2024-12-12 13:01:47 -0500 |
|---|---|---|
| committer | Aiden Woodruff <aiden@aidenw.net> | 2024-12-12 13:01:47 -0500 |
| commit | e50625cfb28c71be7c9ea1780ee9a3da588d4e38 (patch) | |
| tree | 6023cb69b804382866cef7ff6971bc37642b0d3d | |
| parent | 60ac2c15729de56fbe16988026007305dcc5ca26 (diff) | |
| download | wcards-e50625cfb28c71be7c9ea1780ee9a3da588d4e38.tar.gz wcards-e50625cfb28c71be7c9ea1780ee9a3da588d4e38.tar.bz2 wcards-e50625cfb28c71be7c9ea1780ee9a3da588d4e38.zip | |
use std::getline instead of cin >> line
- main.cc (main): replace other instances of cin >> line to avoid
interfering with std::getline for melds.
Signed-off-by: Aiden Woodruff <aiden@aidenw.net>
| -rw-r--r-- | main.cc | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -15,7 +15,7 @@ int main (void) { | |||
| 15 | for (bool ready = false; !ready;) { | 15 | for (bool ready = false; !ready;) { |
| 16 | std::cout << "Menu: (R)ules, (P)lay" << std::endl; | 16 | std::cout << "Menu: (R)ules, (P)lay" << std::endl; |
| 17 | std::string line; | 17 | std::string line; |
| 18 | std::cin >> line; | 18 | std::getline(std::cin, line); |
| 19 | if (toupper(line[0]) == 'R') { | 19 | if (toupper(line[0]) == 'R') { |
| 20 | wcards::gin::print_rules(); | 20 | wcards::gin::print_rules(); |
| 21 | } else if (toupper(line[0]) == 'P') { | 21 | } else if (toupper(line[0]) == 'P') { |
| @@ -26,11 +26,11 @@ int main (void) { | |||
| 26 | wcards::gin::Hand hand(deck); | 26 | wcards::gin::Hand hand(deck); |
| 27 | wcards::Card waste; | 27 | wcards::Card waste; |
| 28 | std::cout << "Score: 0 - 0" << std::endl; | 28 | std::cout << "Score: 0 - 0" << std::endl; |
| 29 | for (bool done = false; !done;) { | 29 | for (bool done = false; !done && std::cin;) { |
| 30 | std::cout << hand << "] stock: ?? waste: " << waste << std::endl; | 30 | std::cout << hand << "] stock: ?? waste: " << waste << std::endl; |
| 31 | std::cout << "Menu: (D)raw, (E)xchange, (M)eld, (G)in or (K)nock?" << std::endl; | 31 | std::cout << "Menu: (D)raw, (E)xchange, (M)eld, (G)in or (K)nock?" << std::endl; |
| 32 | std::string line; | 32 | std::string line; |
| 33 | std::cin >> line; | 33 | std::getline(std::cin, line); |
| 34 | switch (toupper(line[0])) { | 34 | switch (toupper(line[0])) { |
| 35 | case 'D': { | 35 | case 'D': { |
| 36 | wcards::Card draw = deck.draw(); | 36 | wcards::Card draw = deck.draw(); |
