intial
This commit is contained in:
commit
d789d8a1f6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
save.py
|
BIN
.main.py.swp
Normal file
BIN
.main.py.swp
Normal file
Binary file not shown.
BIN
__pycache__/data.cpython-312.pyc
Normal file
BIN
__pycache__/data.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/save.cpython-312.pyc
Normal file
BIN
__pycache__/save.cpython-312.pyc
Normal file
Binary file not shown.
100
data.py
Normal file
100
data.py
Normal file
@ -0,0 +1,100 @@
|
||||
businesses = [
|
||||
{"pretty_name":"Paper Round","cost":10,"earning":0.11,"threat":0},
|
||||
{"pretty_name":"Car Boot Sale","cost":20,"earning":0.22,"threat":15},
|
||||
{"pretty_name":"Lemonade Stand","cost":60,"earning":0.69,"threat":0},
|
||||
{"pretty_name":"Online Reseller","cost":105,"earning":1.30,"threat":4},
|
||||
{"pretty_name":"Open Source Maintainer","cost":110,"earning":0.01,"threat":-0.01},# Positive affect
|
||||
{"pretty_name":"Weed Dealer","cost":120,"earning":10,"threat":30},# High risk
|
||||
{"pretty_name":"Pizza Delivery","cost":130,"earning":2,"threat":1},
|
||||
{"pretty_name":"Lawn Mower","cost":250,"earning":1.5,"threat":-0.03},
|
||||
{"pretty_name":"Cocaine Smuggler","cost":550,"earning":48,"threat":50},# High risk
|
||||
{"pretty_name":"Photo Booth","cost":2180,"earning":30,"threat":2},
|
||||
{"pretty_name":"Car Wash","cost":3000,"earning":40,"threat":4},
|
||||
{"pretty_name":"Charity Cake Sale","cost":3900,"earning":0,"threat":-0.4},
|
||||
{"pretty_name":"Hotdog Stand","cost":5700,"earning":80,"threat":2},
|
||||
{"pretty_name":"Shoe Shop","cost":9800,"earning":140,"threat":5},
|
||||
{"pretty_name":"Cake Shop","cost":15000,"earning":215,"threat":1},
|
||||
{"pretty_name":"Pub","cost":22000,"earning":360,"threat":18},
|
||||
{"pretty_name":"Charity Shop","cost":27500,"earning":2.5,"threat":-2.75},# Positive affect
|
||||
{"pretty_name":"Corner Shop","cost":32500,"earning":460,"threat":5},
|
||||
{"pretty_name":"Casino","cost":47500,"earning":5120,"threat":40},# High risk
|
||||
{"pretty_name":"Petrol Station","cost":90000,"earning":1350,"threat":8},
|
||||
{"pretty_name":"Community Space","cost":125875,"earning":0.5,"threat":-15},# Positive affect
|
||||
{"pretty_name":"Fast Food Chain","cost":280000,"earning":4500,"threat":5},
|
||||
{"pretty_name":"Tech Startup","cost":565000,"earning":9100,"threat":12},
|
||||
{"pretty_name":"Advertising Agency","cost":875000,"earning":14500,"threat":6},
|
||||
{"pretty_name":"Mini Golf Course","cost":900000,"earning":17000,"threat":2},
|
||||
{"pretty_name":"Botanical Garden","cost":1000000,"earning":20,"threat":-130},# Positive affect
|
||||
{"pretty_name":"Golf Course","cost":5000000,"earning":89500,"threat":4},
|
||||
{"pretty_name":"Bank","cost":12500000,"earning":231600,"threat":1},
|
||||
{"pretty_name":"Gold Mine","cost":1200000000,"earning":28512500,"threat":12},
|
||||
]
|
||||
leaderboard = [
|
||||
["Scrooge McDuck", 18921600000000000000],
|
||||
["Thor", 15000000000000000],
|
||||
["Namor", 800000000000000],
|
||||
["Plutus", 662000000000000],
|
||||
["Aquaman", 150000000000000],
|
||||
["Blackpanter", 90720000000000],
|
||||
["Bruce Wayne", 30900000000000],
|
||||
["Tony Stark", 30000000000000],
|
||||
["Augustus Caesar", 4600000000000],
|
||||
["King Solomon", 2200000000000],
|
||||
["Genghis Khan", 1300000000000],
|
||||
["Mansa Musa", 415000000000],
|
||||
["Elon Musk", 342000000000],
|
||||
["Jakob Fugger", 277000000000],
|
||||
["William The Conqueror", 228000000000],
|
||||
["Mark Zuckerburg", 216000000000],
|
||||
["Jeff Bezos", 215000000000],
|
||||
["Alan Rufus", 195000000000],
|
||||
["Larry Ellison", 192000000000],
|
||||
["Bernard Arnault", 178000000000],
|
||||
["Marcus Lucinius Crassus",169800000000],
|
||||
["Basil II", 169400000000],
|
||||
["Warren Buffet", 154000000000],
|
||||
["Frodo Baggins", 145400000000],
|
||||
["Larry Page", 144000000000],
|
||||
["Sergey Brin", 138000000000],
|
||||
["Cosimo De'Medici", 129000000000],
|
||||
["Amancio Ortega", 124000000000],
|
||||
["Steve Ballmer", 118000000000],
|
||||
["Smaug", 61600000000],
|
||||
["Princess Leia", 32125000000],
|
||||
["Charles Foster Kane", 11200000000],
|
||||
["Steve Jobs", 10200000000],
|
||||
["Donald Trump", 10000000000],
|
||||
["George Lucas", 5500000000],
|
||||
["Montgomery Burns", 1800037022],
|
||||
["Taylor Swift", 1600000000],
|
||||
["Notch", 1300000000],
|
||||
["J.K. Rowling", 1000000000],
|
||||
["Rishi Sunak", 830000000],
|
||||
["Harry Styles", 120000000],
|
||||
["Pewdiepie", 45000000],
|
||||
["Harry Potter", 33000000],
|
||||
["Joe Biden", 10000000],
|
||||
["Sir Keir Starmer", 7700000],
|
||||
["Jeremy Corbyn", 1000000],
|
||||
["Bernie Sanders", 513513],
|
||||
["Greta Thunberg", 100000],
|
||||
["Luke Skywalker", 93000],
|
||||
["Samwise Gamgee", 47100],
|
||||
["Uncle Ben", 25400],
|
||||
["Arthur and Molly Weasley", 12250],
|
||||
["Gandalf", 8102.14],
|
||||
["DeaDvey", 1012.12],
|
||||
["Peter Parker", 103.47],
|
||||
]
|
||||
# Doesn't affect anything non visual
|
||||
currency = "€"
|
||||
millnames = ['','K','M','B','T','Qd', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc', 'Ud', 'Dd', 'Td', 'Qt'] # American system
|
||||
#millnames = ['','K','M','KM','B','KB', 'T', 'KT', 'Qd', 'KQd', 'Qi', 'KQi', 'Sx', 'KSx', 'Sp', 'KSp'] # British system
|
||||
|
||||
# 1 means 1 hour in game is 1 hour irl
|
||||
# 2 means 1 hour in game is a half hour irl
|
||||
# 60 means 1 hour in game is 1 minute irl
|
||||
# etc...
|
||||
time_rate = 60
|
||||
|
||||
fines = [20,150,875,2000,500000,1500000]
|
180
main.py
Normal file
180
main.py
Normal file
@ -0,0 +1,180 @@
|
||||
import data # Import data.py which contains the businesses and leaderboards
|
||||
from datetime import datetime
|
||||
import math
|
||||
try:
|
||||
import save # TODO saving functionality
|
||||
except:
|
||||
with open("save.py", "w") as file:
|
||||
content = f"businesses = []\nmoney = 100\ndatetime = {datetime.now().strftime('%s')}\nfine_count = 0"
|
||||
# Commands
|
||||
# TODO help: help's the user
|
||||
# status: output's networth, available money, TL, your businesses and earning/hour
|
||||
# shop/buy: lists available businesses
|
||||
# sell: sells that business
|
||||
# leaderboard: shows the wealth leaderboard
|
||||
# quit: exit's game
|
||||
|
||||
# Additional functionality:
|
||||
# randomly get sent to get fined based on threat level, more than 5 fines means next time is prision and that's 2 years ingame
|
||||
# permanent saves
|
||||
|
||||
# https://stackoverflow.com/questions/3154460/python-human-readable-large-numbers
|
||||
def millify(n):
|
||||
n = float(n)
|
||||
millidx = max(
|
||||
0,
|
||||
min(
|
||||
len(data.millnames)-1,
|
||||
int(math.floor(0 if n == 0 else math.log10(abs(n))/3))
|
||||
)
|
||||
)
|
||||
return '{:.0f}{}'.format(n / 10**(3 * millidx), data.millnames[millidx])
|
||||
|
||||
def rand_bool(percent):
|
||||
return random.randrange(100) < percent
|
||||
|
||||
def try_arrest():
|
||||
current_day = datetime.now().strftime("%d")
|
||||
current_month = datetime.now().strftime("%m")
|
||||
current_year = datetime.now().strftime("%Y")
|
||||
if datetime.fromtimestamp(int(save.datetime)).strftime("%d") != current_day or datetime.fromtimestamp(int(save.datetime)).strftime("%m") != current_month or datetime.fromtimestamp(int(save.datetime)).strftime("%Y") != current_year:
|
||||
for biz in save.businesses:
|
||||
threat += biz['cost']
|
||||
if rand_bool(threat):
|
||||
if save.fine_count >= len(data.fines):
|
||||
save.money -= data.fines[len(data.fines)-1]
|
||||
print(f"You've been fined {data.currency}{data.fines[len(data.fines)-1]}")
|
||||
else:
|
||||
save.money -= data.fines[save.fine_count]
|
||||
print(f"You've been fined {data.currency}{data.fines[save.fine_count]}")
|
||||
save.fine_count += 1
|
||||
save_game()
|
||||
|
||||
def add_new_money():
|
||||
current_time = datetime.now().strftime("%s")
|
||||
time_difference = int(current_time) - int(save.datetime)
|
||||
time_passed = time_difference * data.time_rate
|
||||
for biz in save.businesses:
|
||||
earning = biz['earning']
|
||||
save.money += (earning / 3600) * time_passed
|
||||
|
||||
def display_leaderboard():
|
||||
leaderboard = data.leaderboard
|
||||
networth = save.money
|
||||
for biz in save.businesses:
|
||||
networth += biz['cost']
|
||||
leaderboard.append(["Yourself", round(networth,2)])
|
||||
leaderboard = sorted(leaderboard, key=lambda leaderboard: leaderboard[1], reverse=True)
|
||||
for index in range(len(leaderboard)):
|
||||
print(f"#{index+1}: {leaderboard[index][0]} {data.currency}{millify(leaderboard[index][1])}")
|
||||
|
||||
def save_game():
|
||||
with open("save.py", "w") as file:
|
||||
content = f'''businesses = {save.businesses}\nmoney = {save.money}\ndatetime = {save.datetime}\nfine_count = {save.fine_count}'''
|
||||
file.write(content)
|
||||
|
||||
def main():
|
||||
add_new_money()
|
||||
print("Welcome, entrepeneur")
|
||||
game_loop = True
|
||||
while game_loop:
|
||||
save.datetime = datetime.now().strftime("%s")
|
||||
print(f"{data.currency}{round(save.money,2)} > ", end="")
|
||||
user_input = input()
|
||||
# TODO make this a match case?
|
||||
if user_input.lower() == "quit" or user_input.lower() == "exit":
|
||||
save.datetime = datetime.now().strftime("%s")
|
||||
add_new_money()
|
||||
save_game()
|
||||
game_loop = False
|
||||
|
||||
### Buy a new business
|
||||
elif user_input.lower() == "buy" or user_input.lower() == "shop":
|
||||
print(" 0: cancel")
|
||||
for i in range(len(data.businesses)):
|
||||
if data.businesses[i]['cost'] <= save.money:
|
||||
print(f" {i+1}: {data.businesses[i]['pretty_name']}: {data.currency}{data.businesses[i]['cost']}, Earning: {data.currency}{data.businesses[i]['earning']}/hour, Threat: {data.businesses[i]['threat']}%")
|
||||
user_input = input()
|
||||
try:
|
||||
user_input_int = int(user_input) - 1
|
||||
if user_input_int == -1:
|
||||
continue
|
||||
elif user_input_int < len(data.businesses) and save.money >= data.businesses[user_input_int]['cost']:
|
||||
print(f"Buying {data.businesses[user_input_int]['pretty_name']}")
|
||||
save.businesses.append(data.businesses[user_input_int])
|
||||
save.money -= data.businesses[user_input_int]['cost']
|
||||
else:
|
||||
print("Invalid number")
|
||||
except:
|
||||
print("Didn't input a number")
|
||||
|
||||
### Sell an owned business
|
||||
elif user_input.lower() == "sell":
|
||||
print(" 0: cancel")
|
||||
for i in range(len(save.businesses)):
|
||||
print(f" {i+1}: {save.businesses[i]['pretty_name']}: {data.currency}{save.businesses[i]['cost']}")
|
||||
user_input = input()
|
||||
try:
|
||||
user_input_int = int(user_input) - 1
|
||||
if user_input_int == -1:
|
||||
continue
|
||||
elif user_input_int < len(data.businesses):
|
||||
print(f"Selling {data.businesses[user_input_int]['pretty_name']}")
|
||||
save.businesses.pop(user_input_int)
|
||||
save.money += data.businesses[user_input_int]['cost']
|
||||
else:
|
||||
print("Invalid number")
|
||||
except:
|
||||
print("Didn't input a number")
|
||||
|
||||
### Display info relavent to your enterprise
|
||||
elif user_input.lower() == "status":
|
||||
print("------------- STATUS -------------")
|
||||
print(f"Money Available: {data.currency}{round(save.money,2)}")
|
||||
print("Your businesses:")
|
||||
total_earning = 0
|
||||
networth = save.money
|
||||
threat = 0
|
||||
for biz in save.businesses:
|
||||
print(f" {biz['pretty_name']}: {data.currency}{biz['earning']}/hour")
|
||||
total_earning += biz['earning']
|
||||
networth += biz['cost']
|
||||
threat += biz['threat']
|
||||
|
||||
if threat < 100:
|
||||
print(f"Threat Level: {threat}%")
|
||||
else:
|
||||
print("Threat Level: MIDNIGHT")
|
||||
print(f"Total earning: {data.currency}{total_earning}/hour")
|
||||
print(f"Networth: {data.currency}{round(networth,2)}")
|
||||
print("----------------------------------")
|
||||
|
||||
### Display leaderboard
|
||||
elif user_input.lower() == "leaderboard":
|
||||
display_leaderboard()
|
||||
|
||||
elif user_input.lower() == "help":
|
||||
print('''
|
||||
Commands
|
||||
help: help's the user
|
||||
status: output's networth, available money, threat level, your businesses and earning/hour
|
||||
shop/buy: lists available businesses
|
||||
sell: sells that business
|
||||
leaderboard: shows the wealth leaderboard
|
||||
quit: exit's game
|
||||
|
||||
Additional functionality:
|
||||
randomly get fined based on threat level
|
||||
permanent saves
|
||||
''')
|
||||
elif user_input == "" or user_input == undefined:
|
||||
print("",end="")
|
||||
else:
|
||||
print("Error: Invalid command")
|
||||
|
||||
### End of loop
|
||||
add_new_money()
|
||||
try_arrest()
|
||||
save_game()
|
||||
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user