# A program that plays the game of Paper, Scissors, Rock!

from myro import *
from random import *

def beats(me, you):
   # Does me beat you? If so, return True, False otherwise.
   
   if me == "Paper" and you == "Rock":       # Paper beats rock
      return True
   elif me == "Scissors" and you == "Paper": # Scissors beat paper
      return True
   elif me == "Rock" and you == "Scissors":  # Rock beats scissors
      return True
   else:
      return False

def main():

    speak("Lets play Paper, Scissors, Rock!")
    speak("Make your selections in the windows that pop up.")

    items = ["Paper", "Scissors", "Rock"]

    # Keeping scores
    myScore = yourScore = draws = rounds = 0
    yn = "Yes"
    while yn == "Yes":
        # Play a round of Paper, Scissors, Rock!
        # Computer and Player make their selection...
        # First, computer makes a selection
        myChoice = choice(items)
        
        # Then, layer makes a selection
        speak("Go ahead and make your choice...")
        yourChoice = askQuestion("Select one...", items)
           
        # inform Player of choices    
        speak( "I picked " + myChoice)
        speak( "You picked " + yourChoice)
        
        # Decide if it is a draw or a win for someone
        if myChoice == yourChoice:
            speak( "We both picked the same thing.")
            speak("It is a draw.")
            draws = draws + 1
        elif beats(myChoice, yourChoice):
            speak( "Since " + myChoice + " beats "+yourChoice)
            speak( "I win.")
            myScore = myScore + 1
        else:
            speak( "Since "+yourChoice+ " beats "+myChoice)
            speak( "You win.")
            yourScore = yourScore + 1

        # play again?
        speak( "Wanna play again?")
        yn = askQuestion("Play again?")
        rounds = rounds + 1

    # Game over...    
    # Output scores
    speak("we played " + str(rounds) + " rounds.")
    speak("I won " + str(myScore) + " times.")
    speak("You won " + str(yourScore) + " times.")
    speak("There were " + str(draws) + " draws.")
    speak( "Thank you for playing. Good bye!")
    
main()
