mirror of
https://git.astronand.dev/minecartchris/Stock-Game.git
synced 2026-06-04 17:03:09 -04:00
159 lines
6.7 KiB
Python
159 lines
6.7 KiB
Python
import random
|
|
|
|
def printMenu(Balance, menu):
|
|
if menu == "main":
|
|
print("Balance: "+ str(Balance))
|
|
print("(1: Buy / 2: Sell) Buy/Sell menu: ")
|
|
print("3. See stock prices: ")
|
|
print("4. See remaining time: ")
|
|
print("5. check the index")
|
|
|
|
print("6. goto next day: ")
|
|
elif menu == "prices":
|
|
print("Kwik trip: " + str(kwiktripStockPrice))
|
|
print("Apple computers: " + str(appleStockPrice))
|
|
print("Microsoft: " + str(microsoftStockPrice))
|
|
print("Walmart Super Store: " + str(walmartStockPrice))
|
|
print("Car company: " + str(carStockPrice))
|
|
elif menu == "index":
|
|
print("The index as of day " + str(day) + " is " + str(indexPrice))
|
|
elif menu == "daysleft":
|
|
print("as of today you have " + str(daysleft) + " days left. have fun!")
|
|
"""
|
|
def newday():
|
|
kwiktripStockPrice = kwiktripStockPrice + random.randint(-100.99, 100.99)
|
|
appleStockPrice = appleStockPrice + random.randint(-100.99, 100.99)
|
|
microsoftStockPrice = microsoftStockPriice + random.randint(-100.99, 100.99)
|
|
walmartStockPrice = walmartStockPrice + random.randint(-100.99, 100.99)
|
|
carStockPrice = carStockPrice + random.randint(-100.99, 100.99)
|
|
"""
|
|
|
|
balance = 1000
|
|
kwiktripStockPrice = 100 + random.randint(-100, 100)
|
|
appleStockPrice = 100 + random.randint(-100, 100)
|
|
microsoftStockPrice = 100 + random.randint(-100, 100)
|
|
walmartStockPrice = 100 + random.randint(-100, 100)
|
|
carStockPrice = 100 + random.randint(-100, 100)
|
|
|
|
kwiktrip = 0
|
|
apple = 0
|
|
microsoft = 0
|
|
walmart = 0
|
|
car = 0
|
|
day = 1
|
|
|
|
|
|
indexPrice = (kwiktripStockPrice + appleStockPrice + microsoftStockPrice + walmartStockPrice + carStockPrice) / 5
|
|
|
|
daysleft = int(input("how many days do you wish to play?"))
|
|
|
|
while daysleft > -1:
|
|
printMenu(balance, "main")
|
|
|
|
|
|
stockcost = [kwiktripStockPrice, appleStockPrice, microsoftStockPrice, walmartStockPrice, carStockPrice]
|
|
|
|
|
|
usrinput = input()
|
|
if usrinput == "1":
|
|
print("1. Kwik trip: " + str(kwiktripStockPrice))
|
|
print("2. Apple computers: " + str(appleStockPrice))
|
|
print("3. Microsoft: " + str(microsoftStockPrice))
|
|
print("4. Walmart Super Store: " + str(walmartStockPrice))
|
|
print("5. Car company: " + str(carStockPrice))
|
|
stockinput = int(input("what stock do you want to buy?: "))
|
|
amountinput = int(input("how many stocks?: "))
|
|
|
|
amountcost = int(amountinput) * int(stockcost[int(stockinput)-1])
|
|
rusure = input("are you sure this will cost you " + str(amountcost) + " and you have $" + str(balance) + ": ")
|
|
if balance < amountcost:
|
|
print("you can not complete this purchace your poor")
|
|
else:
|
|
if rusure == "yes" or rusure == "y" or rusure == "Y" or rusure == "Yes":
|
|
balance = balance - amountcost
|
|
if stockinput == 1:
|
|
kwiktrip = kwiktrip + amountinput
|
|
elif stockinput == 2:
|
|
apple = apple + amountinput
|
|
elif stockinput == 3:
|
|
microsoft = microsoft + amountinput
|
|
elif stockinput == 4:
|
|
walmart = walmart + amountinput
|
|
elif stockinput == 5:
|
|
car = car + amountinput
|
|
print("\033c", end="")
|
|
|
|
elif usrinput == "2":
|
|
print("1. Kwik trip: " + str(kwiktripStockPrice) + " you own: " + str(kwiktrip))
|
|
print("2. Apple computers: " + str(appleStockPrice) + " you own: " + str(apple))
|
|
print("3. Microsoft: " + str(microsoftStockPrice) + " you own: " + str(microsoft))
|
|
print("4. Walmart Super Store: " + str(walmartStockPrice) + " you own: " + str(walmart))
|
|
print("5. Car company: " + str(carStockPrice) + " you own: " + str(car))
|
|
stockinput = int(input("what stock do you want to sell?: "))
|
|
amountinput = int(input("how many stocks?: "))
|
|
amountpayout = int(amountinput) * int(stockcost[int(stockinput)-1])
|
|
|
|
rusure = input("are you sure you will sell " + str(stockinput) + " and make " + str(amountpayout) + ": ")
|
|
if rusure == "yes" or rusure == "y" or rusure == "Y" or rusure == "Yes":
|
|
balance = balance + amountpayout
|
|
if stockinput == 1:
|
|
if kwiktrip >= amountinput:
|
|
kwiktrip = kwiktrip - amountinput
|
|
elif stockinput == 2:
|
|
if apple >= amountinput:
|
|
apple = apple - amountinput
|
|
elif stockinput == 3:
|
|
if microsoft >= amountinput:
|
|
microsoft = microsoft - amountinput
|
|
elif stockinput == 4:
|
|
if walmart >= amountinput:
|
|
walmart = walmart - amountinput
|
|
elif stockinput == 5:
|
|
if car >= amountinput:
|
|
car = car - amountinput
|
|
print("\033c", end="")
|
|
elif usrinput == "3":
|
|
printMenu(balance, "prices")
|
|
elif usrinput == "4":
|
|
printMenu(balance, "daysleft")
|
|
elif usrinput == "5":
|
|
printMenu(balance, "index")
|
|
elif usrinput == "6":
|
|
print("\033c", end="")
|
|
day = day + 1
|
|
daysleft = daysleft - 1
|
|
kwiktripStockPrice = abs(kwiktripStockPrice + random.randint(-100, 100))
|
|
appleStockPrice = abs(appleStockPrice + random.randint(-100, 100))
|
|
microsoftStockPrice = abs(microsoftStockPrice + random.randint(-100, 100))
|
|
walmartStockPrice = abs(walmartStockPrice + random.randint(-100, 100))
|
|
carStockPrice = abs(carStockPrice + random.randint(-100, 100))
|
|
|
|
marketCrash = random.randint(0, 1000)
|
|
if marketCrash == 555:
|
|
kwiktripStockPrice = -200
|
|
appleStockPrice = -200
|
|
microsoftStockPrice = -200
|
|
walmartStockPrice = -200
|
|
carStockPrice = -200
|
|
print("the market has crashed every stock is now -200 in value")
|
|
|
|
stockcost = [kwiktripStockPrice, appleStockPrice, microsoftStockPrice, walmartStockPrice, carStockPrice]
|
|
|
|
indexPrice = (kwiktripStockPrice + appleStockPrice + microsoftStockPrice + walmartStockPrice + carStockPrice) / 5
|
|
|
|
print("End game stats")
|
|
print("You started with 1000")
|
|
print("ending the game you have $" + str(balance))
|
|
print("total net worth is $" + str(balance + (kwiktrip * kwiktripStockPrice) + (apple * appleStockPrice) + (microsoft * microsoftStockPrice) + (walmart * walmartStockPrice) + (car * carStockPrice)))
|
|
print("you made " + str((balance - 1000)) + " dollars")
|
|
print("your stocks left over are")
|
|
print("kwik trip you have: " + str(kwiktrip))
|
|
print("apple you have: " + str(apple))
|
|
print("microsoft you have: " + str(microsoft))
|
|
print("walmaart you have: " + str(walmart))
|
|
print("last you have " + str(car) + " in car company.")
|
|
|
|
|
|
|
|
|