So, I have this problem I'm working on, and if someone could point me in the right direction, I'd be so grateful. Let me set it up for you.
I have 1 Python file/module named rooms filled with classes, like so:
class Intro(object):
def __init__(self):
# Setting up some variables here
def description(self):
print "Here is the description of the room you are in"
Which is all cool and stuff right? Then on another file/module, named Engine. I have this:
import rooms
class Engine(object):
def __init__(self, first_class):
self.lvl = first_class
def play_it(self):
next_lvl = self.lvl
while True:
# Get the class we're in & run its description
next_lvl.description() # it works.
# But how do I get the next class when this class is done?
See what I would like to happen is based on the user's decision within each room/level class, the engine call upon a new class w/ its description function/attribute. Does that make sense? Or is there another way I should be thinking about this? Im ass-backwards sometimes. Thanks.