From 37fdb92019e01a27856b5e528aff7bb45228db49 Mon Sep 17 00:00:00 2001 From: Dinko Galetic Date: Sun, 13 Jun 2010 15:51:07 +0000 Subject: Exits are no longer hardcoded in the game. --- (limited to 'library') diff --git a/library/pippy/scholar/scholar.py b/library/pippy/scholar/scholar.py index 13d6245..514f66e 100644 --- a/library/pippy/scholar/scholar.py +++ b/library/pippy/scholar/scholar.py @@ -62,6 +62,26 @@ class Room(GameObject): return True else: return False + @property + def description(self): + msg = self._description + "\n" + + n_exits = len(self.exits) + if n_exits == 0: + msg += "There are no visible exits." + else: + if n_exits == 1: + msg += "There is 1 exit: " + else: + msg += "There are " + str(n_exits) + " exits: " + for exit in self.exits.keys(): + msg += exit.name + ", " + msg = msg.rstrip(", ") + msg += "." + return msg + @description.setter + def description(self, value): + self._description = value #### functions @@ -83,11 +103,10 @@ def create_some_rooms(): starting = Room() balcony = Room() - # TODO: exits shouldn't be hardcoded in room descriptions! - starting.description = "Though rather small, this room looks quite cozy, mostly due to an inviting bed. There is a desk by the north wall, with a painting hung low on the wall so that one can easily glance at it while working at the desk. The door and windows keep most of the noise out. There is an exit to the west." + starting.description = "Though rather small, this room looks quite cozy, mostly due to an inviting bed. There is a desk by the north wall, with a painting hung low on the wall so that one can easily glance at it while working at the desk. The door and windows keep most of the noise out." starting.contains = [starting_painting, starting_bed] starting.add_exit(West, balcony) - balcony.description = "This is a balcony overlooking the large waterfalls over which this mansion was built. Enormous amounts of water spill over it each second and fall hundreds of meters before hitting the ground. It is no wonder many artists choose this particular room when staying here. There is an exit to the east." + balcony.description = "This is a balcony overlooking the large waterfalls over which this mansion was built. Enormous amounts of water spill over it each second and fall hundreds of meters before hitting the ground. It is no wonder many artists choose this particular room when staying here." return [starting, balcony] def opposite_exit(side): -- cgit v0.9.1