# File: Exercise6_1.py
# Purpose:  A program that plays the game of Paper, Scissors, Rock!
# Author: Emily G. Allen (modified from code by D. Kumar)


# import the randrange function
from random import randrange 

# Function: Does me beat you? If so, return True, False otherwise.
def beats(me, you): 
    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: 
         False 

# Main program
def main():# Play Rock, Paper, Scissors!
    print 'Lets play Rock, Paper, Scissors!' # communicate w/user
    
    # define items
    items = ['Rock', 'Paper', 'Scissors']

    done = 'N' # set flag for stopping

    # set tallies to 0
    nwin = 0 # number of wins
    nlose = 0 # number of losses
    ndraw = 0 # number of draws
    while (done !='Y'):  # while not done (done == 'N')
        # Player and Computer make their selection...
        yourChoice = input('Please enter Rock, Paper, or Scissors: ')
        myChoice = items[randrange(0, 3)] 

        # inform Player of choices
        print 'I picked', myChoice 
        print 'You picked', yourChoice 

        # Decide if it is a draw or a win for someone 
        if myChoice == yourChoice:
            print 'We both picked the same thing.'
            print 'It is a draw.'
            ndraw = ndraw + 1
        elif beats(myChoice, yourChoice):
            print 'Since', myChoice, 'beats', yourChoice, '...'
            print 'I win.'
            nlose = nlose + 1
        else: 
            print 'Since', yourChoice, 'beats', myChoice, '...'
            print 'You win.'
            nwin = nwin + 1

        done = input('Are you done playing (Y/N): ')
        

    print '------------------------------------'
    print 'Score: Wins = ', nwin, ' Loses = ', nlose, ' Draws = ', ndraw
    print 'Thank you for playing. Bye!' 

main() # invoke the program

