def destroy(self): 'Get rid of this item and remove it from the index.' container = self.container room = self.room if container is not None: container.remove(self) remove(self) TZContainer.destroy(self) if room is not None: room.action(dict(act='destroy_item', actor=None, item=self))
def __init__(self, name='', short='', long='', owner=None, exits=None, items=None): TZContainer.__init__(self, name, short, long, owner, items) self.settings.append('period') self._exit_ids = PersistentList() if exits is not None: for x in exits: self.addexit(x) self._player_ids = PersistentList() self._mob_ids = PersistentList() self._last_periodic = 0 add(self) self.periodically()
def destroy(self): '''Get rid of this room and remove it from the index. All outgoing exits will also be destroyed. Any mob in the room will be teleported to its home. If this room is its home, the mob will be destroyed. Any player in the room will be teleported to its home. As with a TZContainer, any item in the room will be destroyed. ''' for x in self.exits(): x.destroy() for mob in self.mobs(): if mob.home is self: mob.destroy() else: mob.teleport(mob.home) for player in self.players(): player.teleport(player.home) remove(self) TZContainer.destroy(self)
def __copy__(self): '''A copy of a room will have everything the same except... The exits from the room will lead where the original exits lead, but there will be no connections in to the room. There will be nothing (no contents) in the room. ''' new_room = TZContainer.__copy__(self) for x in self.exits(): new_x = copy.copy(x) new_room.addexit(new_x) return new_room
def look(self, looker): '''Return a multiline message (list of strings) for a player looking at this character. ''' msgs = TZContainer.look(self, looker) items = self.items() if items: msgs.append('') msgs.append('Holding:') for item in items: msgs.append(' ' + unicode(item)) return msgs
def look(self, looker): '''Return a multiline message (list of strings) to a player looking at this room. ''' msgs = TZContainer.look(self, looker) xs = filter(looker.can_see, self.exits()) if xs: msgs.append('') msgs.append('Exits: ') msgs.append(' ' + ', '.join(map(unicode, xs))) #print msgs iis = filter(looker.can_see, self.items()) if iis: msgs.append('') if len(iis) > 1: msgs.append('You see some items here:') else: msgs.append('You see something here:') for item in iis: msgs.append(' ' + unicode(item)) ps = filter(looker.can_see, self.players()) if len(ps) > 1: msgs.append('') for player in ps: if player != looker: msgs.append(unicode(player) + ' is here.') ms = filter(looker.can_see, self.mobs()) if ms: msgs.append('') for mob in ms: msgs.append(unicode(mob) + ' is here.') return msgs
def __str__(self): 'Return the colorized name of this room.' name = TZContainer.__str__(self) return red(name)
def __init__(self, name='', short='', long='', owner=None): TZContainer.__init__(self, name, short, long, owner) add(self) self._bse = 'Item'