# Arup Guha
# 10/15/2020
# Casino Program

import random

# Returns the value of a single standard die roll.
def rollOneDie():
    return random.randint(1,6)

# Returns the sum of n standard dice rolls.
def rollDice(n):
    total = 0
    for i in range(n):
        total += random.randint(1,6)
    return total

def arupsdice():

    # Do the first roll.
    firstRoll = rollDice(2)
    print("Your first roll is", firstRoll)

    # 1 roll win.
    if firstRoll == 11 or firstRoll == 12:
        print("Congrats you win!")
        return True

    # 1 roll loss.
    if firstRoll == 2:
        print("Sorry, this means you lose.")
        return False

    # Get a second roll.
    secondRoll = rollDice(2)
    print("You got", secondRoll,"for your second roll.")

    # Winning case.
    if secondRoll > firstRoll:
        print("You beat your first roll so you win!")
        return True

    # If we get here, we lose.
    print("Sorry, you didn't beat your first roll, so you lose.")
    return False

#
def main():

    money = int(input("How much money do you have?\n"))
    savemoney = money
    
    ans = input("Would you like to play Arup's Game of Dice?\n")

    # Keep playing!
    while money > 0 and (ans == "yes" or ans == "Yes" or ans == 'y' or ans == "Y"):

        # Get wager.
        wager = int(input("How much is your wager?\n"))

        # Play game store result.
        result = arupsdice()

        # Update money.
        if result:
            money += wager
        else:
            money -= wager

        # Update user about their money and see if they want to play again.
        print("Now you have", money,"left after playing.")
        ans = input("Would you like to play again?\n")

    # Ending message.
    print("Thanks for playing, you now have", money,"dollars.")

    # Print their relative status.
    if money > savemoney:
        print("Great job, you earned", money-savemoney," dollars.")
    elif savemoney == money:
        print("You are lucky you did not lose any money!")
    else:
        print("You lost",savemoney-money, "dollars.")

# Run it.
main()

'''
My test of my game
def testarupsgame():
    for i in range(10):
        arupsdice()
        print("-------------------")

testarupsgame()
'''

'''
My test of rollDice
def testRollDice():
    for i in range(50):
        print(rollDice(2))

testRollDice()
'''


