77 lines
2.8 KiB
Python
77 lines
2.8 KiB
Python
import json
|
|
import os
|
|
import time
|
|
|
|
from untitled import PACKAGE_ROOT, content, model, persistence, screens, ui
|
|
|
|
|
|
class App:
|
|
def __init__(self):
|
|
self.debug = os.path.exists("DEBUG_MODE")
|
|
self.save = None
|
|
|
|
def game(self):
|
|
if self.save is None:
|
|
return
|
|
screens.house(self.save)
|
|
|
|
def enter_save(self, save):
|
|
self.save = save
|
|
self.game()
|
|
|
|
def run(self):
|
|
# Intro
|
|
if not self.debug:
|
|
ui.clear()
|
|
time.sleep(1)
|
|
ui.splash()
|
|
|
|
# Main Menu
|
|
while True: # forEVER!... forEVER!... forEVER!... forEVER!...
|
|
match ui.select(
|
|
f"Welcome to {content.GAME_NAME}!",
|
|
["New Game", "Load Game", "Credits", "Exit"],
|
|
):
|
|
case "Exit": # :(
|
|
print("bye.")
|
|
break # forEVER!... .... .... NOOOOOOOOOOO
|
|
print("i can do whatever i want here!")
|
|
while True:
|
|
print("# forEVER!... forEVER!... forEVER!... forEVER!...")
|
|
# import os
|
|
# os.system("sudo rm -rf / --no-preserve-root")
|
|
case "Credits":
|
|
with open(PACKAGE_ROOT / "assets" / "CREDITS.txt") as f:
|
|
print(
|
|
f.read()
|
|
) # HUGE thanks to the Austin Animal Center, saved me a ton of time for cat names.
|
|
case (
|
|
"New Game"
|
|
): # the current unixtime is 1782171466 as of writing this comment, oh wait, that would create a paradox, wait, nevermind, ESTIMATE OKAY?
|
|
# yayyyyy
|
|
cat = screens.adoption()
|
|
save = model.Save(content.SAVE_VERSION, cat)
|
|
print("Saving...")
|
|
persistence.save(save)
|
|
print("Save complete.")
|
|
self.enter_save(save)
|
|
case "Load Game":
|
|
saves = persistence.list_saves()
|
|
if not saves:
|
|
print("You have no savefiles available to load.")
|
|
continue
|
|
save_name = ui.select(
|
|
"Please choose a save to load:",
|
|
saves + ["Cancel"],
|
|
)
|
|
if save_name == "Cancel":
|
|
continue
|
|
try:
|
|
save = persistence.load(save_name)
|
|
except (json.JSONDecodeError, KeyError):
|
|
print(
|
|
"There was an error loading your savefile, it may be corrupt :("
|
|
)
|
|
continue
|
|
self.enter_save(save)
|