/// GH doing rock paper scissors.

/**************************
10. Write a program that plays the game “Rock, Paper, Scissors.”
If you are not familiar with the game do some research (e.g., on
the web using Google). Research is a common task for programmers.
Use a switch-statement to solve this exercise. Also, the machine
should give random answers (i.e., select the next rock, paper,
or scissors randomly). Real randomness is too hard to provide just
now, so just build a vector with a sequence of values to be used as
“the next value.” If you build the vector into the program, it will
always play the same game, so maybe you should let the user enter
some values. Try variations to make it less easy for the user to
guess which move the machine will make next.
****************************/

#include "..\std_lib_facilities.h"
#include <cstdlib>
#include <ctime>

int main() {
    /// 0 = rock
    /// 1 = paper
    /// 2 = scissors
    int hGuess, cGuess, wins{0}, losses{0}, ties{0};
    cout <<   "***********************************************"
         << "\n*    Play the amazing rock, paper, scissors!  *"
         << "\n***********************************************";
    cout << "\nEnter a '0' for rock"
         << "\n        '1' for paper"
         << "\n        '2' for scissors\n\n";
    srand(unsigned(time(0)));
    while(cin >> hGuess) {
        cGuess = rand()%3;
        cout << "\nThe computer guesses " << cGuess;
        if(hGuess == cGuess) {
            ++ties;
            if(hGuess==0) cout << "\nrock ties with rock";
            else if (hGuess == 1) cout << "\npaper ties with paper";
            else cout << "\nscissors ties with scissors.";
        }
        else if(hGuess == 0) {
            if(cGuess == 1) {
                ++losses;
                cout << "\nYou lose: paper wraps rock.";
            }
            else {
                ++wins;
                cout << "\nYou win!  Rock pounds scissors!";
            }
        }
        else if(hGuess == 1) {
            if(cGuess == 2) {
                ++losses;
                cout << "\nYou lose: scissors cuts paper.";
            }
            else {
                ++wins;
                cout << "\nYou win! paper wraps rock!";
            }
        }
        else if(cGuess == 0) {
                ++losses;
                cout << "\nYou lose: Rock crushes scissors.";
            }
        else {
            ++ wins;
            cout << "\nYou win! Scissors cuts paper.";
        }
        cout << "\nwins = " << wins << ", losses = "
             << losses << ", ties = " << ties << endl;
    }

}
