from sys import exit
from sys import argv
from random import randint
from textwrap import dedent
from os.path import exists
from datetime import datetime, timedelta, date
import time
class Timer():
def timer(self):
pass
class Scene():
def enter(self):
exit(1)
class Engine():
def __init__(self, universe_portal):
self.universe_portal = universe_portal
def play(self):
current_scene = self.universe_portal.opening_scene()
last_scene = self.universe_portal.next_scene('finished')
while current_scene != last_scene:
next_scene_name = current_scene.enter()
print(">>> SCENE", next_scene_name) #finds bugs
current_scene = self.universe_portal.next_scene(next_scene_name)
current_scene.enter()
class Death(Scene):
def enter(self):
pass
class Inventory(Scene):
inv = []
def enter(self):
print(dedent("""
This is your inventory
"""))
print(inv)
return 'portal'
class Portal(Scene):
def enter(self):
print(dedent("""You are safe at home. What do you want to do?
[ Check Inventory ] [ Adventure ] [ Brew ]
"""))
choice = input("> ")
if 'inventory' in choice.lower():
return 'inventory'
elif 'adventure' in choice.lower():
return 'adventure'
elif 'brew' in choice.lower():
return 'brew_system'
else:
print("DOES NOT COMPUTE")
return 'portal'
class Adventure(Scene):
def enter(self):
print(dedent(""""
Where shall we start our adventure?
[ Rivers of Plenty ] [ Sugar HELL ] [ Ginger Forest ]
"""))
space_travel = input("> ")
if 'rivers' in space_travel.lower():
return 'rivers_of_plenty'
elif 'hell' in space_travel.lower():
return 'sugar_hell'
elif 'ginger' in space_travel.lower():
return 'ginger_forest'
else:
print("CANNOT COMPUTE")
return 'portal'
class BrewSys(Scene):
def enter(self):
pass
class RiversOfPlenty(Scene):
def enter(self):
print(dedent("""
You are soaked. Goddess appears before you. I grant you the power of clean water."""))
inv.append('water')
return 'portal'
class SugarHell(Scene):
def enter(self):
pass
def SweetSatan(self):
pass
class GingerForest(Scene):
def enter(self):
pass
def GingerElve(self):
pass
class Finished(Scene):
def enter(self):
pass
class UniversePortal():
scenes = {
'portal': Portal(),
'inventory': Inventory(),
'adventure': Adventure(),
'brew_system': BrewSys(),
'sugar_hell': SugarHell(),
'rivers_of_plenty': RiversOfPlenty(),
'ginger_forest': GingerForest(),
'finished': Finished()
}
def __init__(self, start_scene):
self.start_scene = start_scene
def next_scene(self, scene_name):
val = UniversePortal.scenes.get(scene_name)
return val
def opening_scene(self):
return self.next_scene(self.start_scene)
inv = Inventory()
a_universe = UniversePortal('portal')
a_game = Engine(a_universe)
a_game.play()
I have had a really hard time getting back on track after stopping at ex. 43 trying to do my own game. I wanted to incorporate other topics learned, like appending in a list, pulling from a file, writing in a file… I think I bit off more than I could chew and I am have walked away from it so many times that I have forgotten a lot of what I learned. I do not know what the best course of action is. Should I move on to the next topic? Where should I restart? Where can I find a good summary?