from random import randint
import time

balance = 100
day = 1

print ("Welcome to the Gold Rush Game!!!")
time.sleep(1)
print ("There are three portals for you to pick from every day.")
time.sleep(1)
print ("You can either win money, lose money, or DIE!!")
time.sleep(1)
print ("Try to survive for as long as you can!! GOOD LUCK!!")
time.sleep(1)
print ()

while (balance > 0):
    print()
    print ("DAY", day)
    portal = input("Choose a portal (1/2/3): ")
    
    chance = randint(1, 10) # picking random chance

    # if input is invalid
    while (portal != "1" and portal != "2" and portal != "3"):
        print ("INVALID!!!")
        print()
        portal = input("Choose a portal (1/2/3): ")

    print()
    print ("You have entered portal ", portal, "...........", sep="")
    time.sleep(0.5)
    print ("Generating chances...")
    time.sleep(1)
    print()
    
    if (portal == "1"):
        if (chance <= 8):
            print ("You won $", balance, "!!", sep = "")
            balance = balance * 2
        else:
            print ("You lost $300!!!")
            balance = balance - 300

    elif (portal == "2"):
        if (chance <= 8):
            print ("You won $400!!")
            balance = balance + 400
        elif (chance == 9):
            print ("You lose $500!!")
            balance = balance - 500
        else:
            print ("You lost $", balance*0.2, "!!", sep = "")
            balance = balance * 0.8
    elif (portal == "3"):
        if (chance == 1):
            print ("You won $", balance*4, "!!", sep = "")
            balance = balance * 5
        elif (chance <= 4):
            print ("You lost $", balance*0.5, "!!", sep = "")
            balance = balance * 0.5
        elif (chance <= 9):
            print ("You won $2000!")
            balance = balance + 2000
        else:
            print ("You died!!")
            break
    
    time.sleep(1)
    print ("Current balance: $", balance, sep="")
    print()
    day = day + 1
    time.sleep(1)
    print ("----------------------------")
    
print()
print ("You survived for", day - 1, "days. Better luck next time!!")
