Changeset 114 for adventure/world.py
- Timestamp:
- 10/14/07 17:08:42 (3 years ago)
- Files:
-
- 1 modified
-
adventure/world.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
adventure/world.py
r112 r114 49 49 50 50 def move_thing(self, thing, newplace): 51 for t in each_thing_by_place(thing.place):51 for t in self.each_thing_by_place(thing.place): 52 52 # Call leave hooks 53 53 t.on_leave(thing, newplace) … … 73 73 thing.place = newplace 74 74 75 for t in each_thing_by_place(thing.place):75 for t in self.each_thing_by_place(thing.place): 76 76 # Broadcast availability presence to enterer 77 77 if t.presence: … … 95 95 thing.see(place(newplace)) 96 96 97 for t in each_thing_by_place(thing.place):97 for t in self.each_thing_by_place(thing.place): 98 98 # Call enter hooks 99 99 t.on_enter(thing, oldplace) 100 100 101 def handle_presence( pres):101 def handle_presence(self, _, pres): 102 102 # A help for the irritated first: 103 103 if pres.getType() == 'subscribe': … … 139 139 player.presence = pres 140 140 self.players[player.name] = player 141 move_thing(player, attributes['start'])141 self.move_thing(player, self.start) 142 142 player.send_message('Help!', 'Send "?" to get a list of available commands any time.') 143 143 # Or broadcast updated presence … … 145 145 player.presence = pres 146 146 147 for t in each_thing_by_place(player.place):147 for t in self.each_thing_by_place(player.place): 148 148 # Broadcast presence to all who are here 149 149 pres = Presence(node=player.presence) … … 156 156 del self.players[player.name] 157 157 158 def handle_message( msg):158 def handle_message(self, _, msg): 159 159 player = None 160 160 for thing in self.things.values(): … … 170 170 171 171 if not command(player, msg.getBody()): 172 for thing in each_thing_by_place(player.place):172 for thing in self.each_thing_by_place(player.place): 173 173 thing.send_message(player.iname, msg.body) 174 174 175 def command( player, text):175 def command(self, player, text): 176 176 if text == '?': 177 177 player.send_message(None, '(Command) who') … … 195 195 newplace = None 196 196 197 for go in oldplace.each_element('go'):198 if go.attributes['spec']== what:199 newplace = go.attributes['place']197 for name, place in oldplace.exits.items(): 198 if name == what: 199 newplace = place 200 200 201 201 if newplace: 202 move_thing(player, newplace)202 self.move_thing(player, newplace) 203 203 else: 204 204 player.send_message(None, 'You cannot go there')
