diff --git a/README.md b/README.md index 334dca5..17f97e8 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,4 @@ I used to play this game when I was like 7 and it's off the play store so I thou # Additional functionality: * randomly get fined based on threat level * permanent saves + * businesses·lose·10%·of·their·value·upon·purchase diff --git a/data.py b/data.py index 74888bb..259df4f 100644 --- a/data.py +++ b/data.py @@ -28,8 +28,9 @@ businesses = [ {"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":"Fancy Hotel", "cost":1710569,"earning":28933,"threat":4}, {"pretty_name":"Golf Course", "cost":5000000,"earning":89500,"threat":4}, - {"pretty_name":"Drug Empire", "cost":6730000,"eanring":828240,"threat":80},# High Risk + {"pretty_name":"Drug Empire", "cost":6730000,"earning":828240,"threat":80},# High Risk {"pretty_name":"Bank", "cost":12500000,"earning":231600,"threat":1}, {"pretty_name":"Hogwarts", "cost":38890000,"earning":690000,"threat":12}, {"pretty_name":"Car Manufacturer", "cost":95000000,"earning":1853838,"threat":6}, @@ -39,11 +40,11 @@ businesses = [ {"pretty_name":"Record Label", "cost":16086117467,"earning":377219792,"threat":4}, {"pretty_name":"North Korean Hackers", "cost":49090934652,"earning":1197973460,"threat":390},# High Risk {"pretty_name":"Royal Mint", "cost":31418198177,"earning":754581418,"threat":0}, + {"pretty_name":"HS2", "cost":80265000000,"earning":50,"threat":2000},# Joke inclusion, High Risk {"pretty_name":"Nuclear Power Plant", "cost":149813643350,"earning":3804520446,"threat":12}, {"pretty_name":"Mithril Mine", "cost":187267054187,"earning":4793695763,"threat":24},# High Risk {"pretty_name":"Asgardian Bank", "cost":2730000000000,"earning":76800000000,"threat":2}, {"pretty_name":"Atlantis", "cost":39655341208057,"earning":1229033018189.84,"threat":14}, - {"pretty_name":"HS2", "cost":80265000000000,"earning":50,"threat":2},# Joke inclusion {"pretty_name":"Galactic Empire", "cost":577061163611609,"earning":19679320186973,"threat":80},# High Risk {"pretty_name":"McDuck Enterprises", "cost":1752500000000000,"earning":62497524783840,"threat":4}, {"pretty_name":"Silmaril Factory", "cost":40000000000000000,"earning":1588731290169286,"threat":84},# High Risk @@ -102,7 +103,8 @@ leaderboard = [ ["Harry Potter", 33000000], ["Joe Biden", 10000000], ["Sir Keir Starmer", 7700000], - ["Jeremy Corbyn", 1000000], + ["Frank Abagnale Jr.", 2500000], + ["Jeremy Corbyn", 925000], ["Bernie Sanders", 513513], ["Greta Thunberg", 100000], ["Luke Skywalker", 93000], diff --git a/main.py b/main.py index 3840aea..8a3cafe 100644 --- a/main.py +++ b/main.py @@ -4,21 +4,25 @@ from datetime import datetime import math try: import save # TODO saving functionality +# If the save file doesn't exist, create one except: with open("save.py", "w") as file: content = f"businesses = []\nmoney = 100\ndatetime = {datetime.now().strftime('%s')}\nfine_count = 0" -# Commands - # 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 - # TODO upgrade (?): upgrades some stats about a business for some money + file.write(content) + import save +help_text = '''# Commands: + * help: help's the user + * status: output's networth, available money, TL, your businesses and earning/hour + * shop/buy: lists available businesses + * sell: sells one of your businesses + * leaderboard: shows the wealth leaderboard + * quit: exit's game + * TODO upgrade (?): upgrades some stats about a business for some money # 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 + * 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 + * businesses lose 10% of their value upon purchase''' # This function accepts a number and returns the value millified @@ -65,6 +69,11 @@ def try_fine(): save.fine_count += 1 # Increase the amount of times you've been fined save_game() +def input_command(): + user_input = input() + user_input = user_input.strip() + return user_input + def add_new_money(): current_time = datetime.now().strftime("%s") time_difference = int(current_time) - int(save.datetime) @@ -95,9 +104,11 @@ def main(): while game_loop: save.datetime = datetime.now().strftime("%s") print(f"{data.currency}{millify(save.money)} > ", end="") - user_input = input() + user_input = input_command() # TODO make this a match case? - if user_input.lower() == "quit" or user_input.lower() == "exit": + if user_input == "" or user_input is None: + print("",end="") + elif user_input.lower() == "quit" or user_input.lower() == "exit": save.datetime = datetime.now().strftime("%s") add_new_money() save_game() @@ -107,17 +118,24 @@ def main(): 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}{millify(data.businesses[i]['cost'])}, Earning: {data.currency}{millify(data.businesses[i]['earning'])}/hour, Threat: {data.businesses[i]['threat']}%") - user_input = input() + if save.money >= data.businesses[i]['cost']: + print(" * ",end="") + else: + print(" ",end="") + print(f"{i+1}: {data.businesses[i]['pretty_name']}: {data.currency}{millify(data.businesses[i]['cost'])}, Earning: {data.currency}{millify(data.businesses[i]['earning'])}/hour, Threat: {data.businesses[i]['threat']}%") + user_input = input_command() 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'] + elif user_input_int < len(data.businesses): + if 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.businesses[len(save.businesses)-1]['cost'] *= 0.9 # Remove 10% of it's value so the sell price is slightly less + save.money -= data.businesses[user_input_int]['cost'] + else: + print("You can't afford that!") else: print("Invalid number") except: @@ -128,7 +146,8 @@ def main(): print(" 0: cancel") for i in range(len(save.businesses)): print(f" {i+1}: {save.businesses[i]['pretty_name']}: {data.currency}{millify(save.businesses[i]['cost'])}") - user_input = input() + user_input = input_command() + user_input_int = int(user_input) - 1 if user_input_int == -1: continue @@ -166,23 +185,9 @@ def main(): 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 == "": - print("",end="") + print(help_text) else: - print("Error: Invalid command") + print(f"Error: Invalid command: '{user_input}'") ### End of loop add_new_money()