def ability_mutate(self, sentence): """mutate object to new_type This will mutate an object into a different type of object. """ mutator = sentence.directObject() try: newtype = sentence.indirectString("to") newtype = self.code_space[newtype] except: error.Failure("You don't know of any such type.") newtype = reflect.getcurrent(newtype) x = issubclass(newtype, reflect.getcurrent(thing.Thing)) assert x, "You shouldn't mutate Things to types which are not Things." if not reflect.isinst(mutator, newtype): mutator.__class__ = newtype
def ability_dig(self, sentence): """dig {direction} Dig creates a new room (and an exit to that room from the current room, and back again) in the direction specified. See also "undig" to totally undo this process, or "tunnel" and "barricade" to edit or create new exits for your new room.""" direction = sentence.directString() try: name = sentence.indirectString("to") except: name = "Untitled Room" p = self.place r = room.Room(name, self.reality) p.connectExit(direction, r) r.connectExit(geometry.reverse(direction), p) if self.code_space.has_key("log_dig") and self.code_space["log_dig"] is not None: self.code_space["log_dig"](self.name, r, time.time())
def ability_portal(self, sentence): """portal {direction} to {room} Portal creates a new, one-way passage from the room you are currently in to the room specified by "to". (For example, "portal east to mansion basement" would create a new exit to the east, leading to the "mansion basement" room. Note that this would NOT create a corresponding exit in "mansion basement" leading back to the room you were in.) This can be undone with "barricade". See also "tunnel" and "dig".""" direction = sentence.directString() try: rs = sentence.indirectString("to") r = self.reality.get(rs) p = self.place p.connectExit(direction, r) except: self.hears('Please specify a destination room! (For example, "dig west to mansion cellar")')
def ability_tunnel(self, sentence): """untunnel {direction} to {room} Tunnel creates a new, two-way passage in the room you are currently in, which links to the room specified with "to" and back again. (For example, "tunnel west to mansion cellar" would create a new exit to the west, leading to the "mansion cellar" room, and also add an east exit to "mansion cellar" that led back to the room you're currently in.) This can be easily undone with "untunnel". Compare "dig" and "".""" direction = sentence.directString() try: rs = sentence.indirectString("to") r = self.reality.get(rs) p = self.place p.connectExit(direction, r) r.connectExit(geometry.reverse(direction), p) except: self.hears('Please specify a destination room! (For example, "dig west to mansion cellar")')