redo screen system
This commit is contained in:
@@ -7,6 +7,12 @@ from untitled import PACKAGE_ROOT, content, model, persistence, screens, ui
|
|||||||
class App:
|
class App:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.debug = os.path.exists("DEBUG_MODE")
|
self.debug = os.path.exists("DEBUG_MODE")
|
||||||
|
self.save = None
|
||||||
|
|
||||||
|
def game(self):
|
||||||
|
if self.save is None:
|
||||||
|
return
|
||||||
|
screens.house(self.save)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Intro
|
# Intro
|
||||||
@@ -42,3 +48,5 @@ class App:
|
|||||||
print("Saving...")
|
print("Saving...")
|
||||||
persistence.save(save)
|
persistence.save(save)
|
||||||
print("Save complete.")
|
print("Save complete.")
|
||||||
|
self.save = save
|
||||||
|
self.game()
|
||||||
|
|||||||
3
untitled/screens/__init__.py
Normal file
3
untitled/screens/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from untitled.screens.adoption import adoption as adoption
|
||||||
|
from untitled.screens.common import options as options
|
||||||
|
from untitled.screens.house import house as house
|
||||||
12
untitled/screens/common.py
Normal file
12
untitled/screens/common.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from untitled import ui
|
||||||
|
|
||||||
|
|
||||||
|
def options():
|
||||||
|
while True:
|
||||||
|
match ui.select("Please choose an option:", ["Save", "Save and quit", "Back"]):
|
||||||
|
case "Back":
|
||||||
|
return "back"
|
||||||
|
case "Save":
|
||||||
|
return "save"
|
||||||
|
case "Save and quit":
|
||||||
|
return "savequit"
|
||||||
23
untitled/screens/house.py
Normal file
23
untitled/screens/house.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from untitled import model, persistence, ui
|
||||||
|
from untitled.screens.common import options
|
||||||
|
|
||||||
|
|
||||||
|
def house(save: model.Save):
|
||||||
|
print("Welcome to your house!")
|
||||||
|
while True:
|
||||||
|
match ui.select("What do you want to do?", ["Check on your cat", "Menu"]):
|
||||||
|
case "Check on your cat":
|
||||||
|
print(save.cat.name)
|
||||||
|
case "Menu":
|
||||||
|
result = options()
|
||||||
|
match result:
|
||||||
|
case "save":
|
||||||
|
print("Saving...")
|
||||||
|
persistence.save(save)
|
||||||
|
print("Done")
|
||||||
|
case "savequit":
|
||||||
|
if ui.confirm("Are you sure you want to quit?"):
|
||||||
|
print("Saving...")
|
||||||
|
persistence.save(save)
|
||||||
|
print("Done")
|
||||||
|
break
|
||||||
Reference in New Issue
Block a user