diff options
| author | Jeff Armstrong <jeff@approximatrix.com> | 2013-07-27 14:42:40 -0400 |
|---|---|---|
| committer | Jeff Armstrong <jeff@approximatrix.com> | 2013-07-27 14:42:40 -0400 |
| commit | 0e7c76d6daee9c182a5d01c0227b77dcc36a915c (patch) | |
| tree | 01ee42ad62090a92185cfe2213e5eab3c41de89e /src/game.py | |
| parent | f24f3866b5cc5ccf0eaf32489892e14f6d94f899 (diff) | |
| download | pyohio2013-0e7c76d6daee9c182a5d01c0227b77dcc36a915c.tar.gz pyohio2013-0e7c76d6daee9c182a5d01c0227b77dcc36a915c.zip | |
done
Diffstat (limited to 'src/game.py')
| -rw-r--r-- | src/game.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/game.py b/src/game.py index 0a587e4..800d3ac 100644 --- a/src/game.py +++ b/src/game.py @@ -1,12 +1,17 @@ import cmd from room import get_room import textwrap +import shutil +import tempfile class Game(cmd.Cmd): def __init__(self): cmd.Cmd.__init__(self) - self.loc = get_room(1) + self.dbfile = tempfile.mktemp() + shutil.copyfile("game.db", self.dbfile) + + self.loc = get_room(1, self.dbfile) self.look() def move(self, dir): @@ -14,8 +19,11 @@ class Game(cmd.Cmd): if newroom is None: print("you can't go that way") else: - self.loc = get_room(newroom) + self.loc = get_room(newroom, self.dbfile) self.look() + + if newroom==13: + exit() def look(self): print(self.loc.name) @@ -52,6 +60,11 @@ class Game(cmd.Cmd): """Leaves the game""" print("Thank you for playing") return True + + def do_save(self, args): + """Saves the game""" + shutil.copyfile(self.dbfile, args) + print("The game was saved to {0}".format(args)) if __name__ == "__main__": g = Game() |
