-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBanana Simulator.py
143 lines (134 loc) · 5.25 KB
/
Banana Simulator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import time
import random
import threading
import json
file = open('F.json', 'r+')
data = json.load(file)
def end():
raise SystemExit
print("It's a summer night, you're drunk when one of your friends jokes about a banana business")
time.sleep(3)
print("You then think, 'It might work out'")
time.sleep(2)
print("You walk out the bar and go on your computer")
time.sleep(2)
print("'How to make a profit with bananas'")
time.sleep(2)
print("You start a business and begin your journey")
time.sleep(2)
cash = 50
print("Your current cash is: $" + str(cash))
print("Each banana will cost you 25 cents.")
print("Goal: Get as much cash as possible, don't go bankrupt or sell all your bananas!")
stockmarket = round(random.uniform(0.10, 0.40), 2)
day = 0
def generate_random_stock_price():
global stockmarket
while True:
stockmarket = round(random.uniform(0.10, 0.40), 2)
time.sleep(30)
def day_system():
global day
while True:
day += 1
data['day'] = str(day)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
print(f" Day {day}")
time.sleep(random.randint(120,180))
stock_thread = threading.Thread(target=generate_random_stock_price)
stock_thread.daemon = True
stock_thread.start()
day_thread = threading.Thread(target=day_system)
day_thread.daemon = True
day_thread.start()
while True:
try:
bananns = input("how many bananas do you want? \n")
if bananns == 'uwu' or "~" in bananns:
print("...")
time.sleep(2)
print("You do realize that just because it's from freakybob doesn't mean you have to be freaky")
time.sleep(4)
print("Right..?")
time.sleep(4)
print("Anyway, go to jail.")
end()
bananns = int(bananns)
# data.update({"bananas": bananns}) | this works, but doesn't add "quotes" around the number
data['bananas'] = str(bananns)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
break
except ValueError:
print("Gtfo now, you failure (ValueError)")
cash -= (bananns * 0.25)
if cash < 0:
print("You already went fucking bankrupt. Nerd.")
print("You are now: $" + str(cash) + " in debt!")
end()
else:
print("Your cash is now: $" + str(cash))
data['cash'] = str(cash)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
print("Bananas: " + str(bananns))
time.sleep(0.5)
while True:
menuchoice = input("what are you gonna do now\n").lower()
if menuchoice == 'sell':
try:
sell = int(input(f"how many sell? (current stock price: {stockmarket})\n"))
bananns -= sell
if bananns < 0:
print("YOU SOLD MORE THAN YOU HAVE! FRAUD! FRAUD!")
time.sleep(1)
print("You're now in jail. Luni is in here too, watch out buddy!")
end()
elif bananns == 0:
print("You have no bananas anymore. Dang, crazy.")
print("Game over")
data['bananas'] = str(bananns)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
end()
else:
cash += (sell * stockmarket)
print("Your cash is now: $" + str(cash))
print("You now have: " + str(bananns) + " bananas!")
data['bananas'] = str(bananns)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
data['cash'] = str(cash)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
except ValueError:
print("CRITICAL EXCEPTION! bananas invalid :(")
elif menuchoice == 'stocks':
print("Current stocks are: " + str(stockmarket) + " per banana!\n")
elif menuchoice == 'buy':
try:
buy = int(input(f"buy how many bananas? (current stock price: {stockmarket})\n"))
cash -= (buy * stockmarket)
bananns += buy
if cash < 0:
print("You went broke, your wife left you because of this")
end()
else:
print("Your cash is now: $" + str(cash))
print("You now have: " + str(bananns) + " bananas!")
data['bananas'] = str(bananns)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
data['cash'] = str(cash)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)
except ValueError:
print("CRITICAL EXCEPTION! bananas invalid :(")
elif menuchoice == 'rodrick':
print("Rodrick took 10% of your bananas.")
bananns = round(bananns * 0.9)
print("Your bananas are now: " + str(bananns))
data['bananas'] = str(bananns)
with open('F.json', 'w') as JSONFile:
json.dump(data, JSONFile, ensure_ascii=False, indent=4)