示例#1
0
文件: area.py 项目: semtle/ShinyMUD
    def load(self):
        """Load all of this area's objects from the database."""
        if self.dbid:
            items = self.world.db.select("* from build_item where area=?",
                                         [self.name])
            for item in items:
                item['area'] = self
                self.items[str(item['id'])] = BuildItem(item)
            scripts = self.world.db.select("* from script where area=?",
                                           [self.name])
            for script in scripts:
                script['area'] = self
                self.scripts[str(script['id'])] = Script(script)
            npcs = self.world.db.select("* from npc where area=?", [self.name])
            for npc in npcs:
                npc['area'] = self
                self.npcs[str(npc['id'])] = Npc(npc)
            rooms = self.world.db.select("* from room where area=?",
                                         [self.name])
            for room in rooms:
                room['area'] = self
                new_room = Room(room)
                new_room.reset()
                self.rooms[str(room['id'])] = new_room

            self.time_of_last_reset = time.time()
示例#2
0
文件: area.py 项目: semtle/ShinyMUD
 def new_room(self, room_dict=None):
     """Add a new room to this area's room list."""
     if room_dict:
         # Create a new room with pre-initialized data
         room_dict['area'] = self
         new_room = Room(room_dict)
     else:
         # Create a new 'blank' room
         new_room = Room.create(self, self.get_id('room'))
     new_room.save()
     self.rooms[str(new_room.id)] = new_room
     return new_room