'''
Created on Jun 17, 2013

@author: Jared

Let's the user play craps, utilizes a random functions.
Python translation of Arup's code
'''

from random import randint

def main():
        # Simulate dice roll.
        die1 = randint(1, 6)
        die2 = randint(1, 6) 
        sum = die1 + die2

        # Let the user know what was rolled.
        print("You rolled a " + str(sum) + " for your first roll.")
        dummy = input("Hit enter to continue.\n")

        # Take care of the winning case.
        if (sum == 7 or sum == 11):
            print("You win!!!")

        # The losing case.
        elif (sum == 2 or sum == 3 or sum == 12):
            print("Sorry, you lose.")

        # The case where you play on.
        else:
            # Print out the rules for the user.
            print("The game will continue.")
            print("Your first roll of " + str(sum) + " is now your point.")
            print("If you roll that again before a 7, you win!")
            dummy = input("Hit enter to continue.\n")

            point = sum

            # Continue until 7 or the point is hit.
            while True:
                # Next roll.
                die1 = randint(1, 6)
                die2 = randint(1, 6) 
                sum = die1 + die2

                # Print out the value for the user.
                print("You rolled a " + str(sum) + " for this roll.")
                dummy = input("Hit enter to continue.\n")
                
                # Simulates a do-while loop
                if not(sum != 7 and sum != point):
                    break;
    
            # You win!
            if (sum == point):
                print("You win, you hit your point!")

            # You lose :(
            else:
                print("Sorry, you lose. You got a 7 before your point.")  
                
# runs main module on startup
if __name__ == "__main__":
    main()
