Permalink
Browse files

Load map from level dir.

  • Loading branch information...
1 parent 464490c commit a9e7e79b7d85c5d677882979cacc9184f96c5cb1 @Ignas Ignas committed Jan 28, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 snakemud/interpreter.py
View
@@ -16,8 +16,8 @@
class Map(object):
- def __init__(self):
- self.data = pkg_resources.resource_string('snakemud', 'map.txt').splitlines()
+ def __init__(self, level=1):
+ self.data = pkg_resources.resource_string('snakemud', 'maps/l%d.txt' % level).splitlines()
self.start_pos = []
for y in range(len(self.data)):
self.data[y] = list(self.data[y])
@@ -41,7 +41,8 @@ def __setitem__(self, (x, y), c):
class Interpreter(object):
"""Stateful command interpeter for a single player."""
- map = Map()
+ level = 1
+ map = Map(level=level)
greeting = "You are hungry. Type 'help' if you feel lost."
@@ -343,7 +344,7 @@ def do_compass(self, *args):
def do_restart(self, *args):
"""start the game from the very beginning"""
- self.map = Map()
+ self.map = Map(level=self.level)
self.last_event = None
self.seen = None
pos = list(self.map.start_pos)

0 comments on commit a9e7e79

Please sign in to comment.