diff options
author | Dinko Galetic <dgaletic@everflame.(none)> | 2010-06-08 22:58:13 (GMT) |
---|---|---|
committer | Dinko Galetic <dgaletic@everflame.(none)> | 2010-06-08 22:58:13 (GMT) |
commit | b959165961848acdbf98607e7df84b98a4753bf3 (patch) | |
tree | 7bf154aa36c0457f0d48bc16cb1bae8784dcc07e | |
parent | a16d73ba67f73b3625dae655990787b41dfb63c5 (diff) |
Added Room class.
-rw-r--r-- | library/pippy/scholar/scholar.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/library/pippy/scholar/scholar.py b/library/pippy/scholar/scholar.py index 1f7224f..9e1022b 100644 --- a/library/pippy/scholar/scholar.py +++ b/library/pippy/scholar/scholar.py @@ -21,3 +21,23 @@ class Player(Game_object): self.name = name self.position = "A room object goes here!" self.known_commands = ["examine", "go"] + +class Room(Game_object): + def __init__(self): + Game_object.__init__(self) + self.contains = [] + self.exits = {} + self.methods.append("go") + self.aliases = ["room"] + # TODO: Think about the case when two rooms share one object + # (such as a door) + def add_exit(self, through, to, two_way = True): + if self.exits.has_key(through) == False: + if two_way: + if to.exits.has_key(opposite_exit(through)) == False: + to.exits[opposite_exit(through)] = self + else: + return "That room already has that exit" + self.exits[through] = to + else: + return "This room already has this exit" |