From b959165961848acdbf98607e7df84b98a4753bf3 Mon Sep 17 00:00:00 2001 From: Dinko Galetic Date: Tue, 08 Jun 2010 22:58:13 +0000 Subject: Added Room class. --- (limited to 'library') 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" -- cgit v0.9.1