Changeset 114
Legend:
- Unmodified
- Added
- Removed
-
adventure/adventuremuc.py
r112 r114 32 32 def send(self, worldnode, worldresource, stanza): 33 33 stanza.setFrom(JID(node=worldnode, domain=self.jid.domain, resource=worldresource)) 34 self.send(stanza)34 Component.send(self, stanza) 35 35 36 def handle_iq(self, iq):36 def handle_iq(self, _, iq): 37 37 #print "iq: from #{iq.from} type #{iq.type} to #{iq.to}: #{iq.queryns}" 38 38 … … 87 87 # self.component.send(answer) 88 88 89 def handle_presence(self, pres):89 def handle_presence(self, _, pres): 90 90 print 'presence: from %s type %s to %s' % (pres.getFrom(), pres.getType(), pres.getTo()) 91 91 92 world = self.worlds[pres. to.node]92 world = self.worlds[pres.getTo().getNode()] 93 93 if not world: 94 answer = pres. answer94 answer = pres.buildReply() 95 95 answer.setType('error') 96 96 #answer.add(Jabber::Error.new('item-not-found', 'The world you are trying to reach is currently unavailable.')) 97 97 self.component.send(answer) 98 98 else: 99 world.handle_presence( pres)99 world.handle_presence(self,pres) 100 100 return True 101 101 102 def handle_message( msg):102 def handle_message(self, _, msg): 103 103 print 'message: from %s type %s to %s: %s' % (msg.getFrom(), msg.getType(), msg.getTo(), repr(msg.getBody())) 104 104 -
adventure/player.py
r108 r114 22 22 23 23 def send_message(self, fromresource, text, subject=None): 24 msg = Message( jid, text)24 msg = Message(self.jid, text) 25 25 msg.setType('groupchat') 26 26 if subject: -
adventure/thing.py
r109 r114 14 14 self.UID = 0 15 15 self.place = None 16 17 def command_name(self):18 if attributes['command-name']:19 return attributes['command-name']20 return self.iname()21 16 22 def jid( ):17 def jid(self): 23 18 return None 24 19 25 def presence( ):20 def presence(self): 26 21 xe = None 27 22 #for pres in each_element('presence'): … … 33 28 return xe 34 29 35 def see( place):30 def see(self, place): 36 31 pass 37 32 38 def send_message( fromresource, text, subject=None):33 def send_message(self, fromresource, text, subject=None): 39 34 pass 40 35 41 def send_message_to_place( fromresource, text):36 def send_message_to_place(self, fromresource, text): 42 37 for thing in self.world.each_element('thing'): 43 38 if thing.place == place: 44 39 thing.send_message(fromresource, text) 45 40 46 def on_enter( thing, from_):41 def on_enter(self, thing, from_): 47 42 for c in each_element('on-enter'): 48 43 command(thing, c, [from_]) 49 44 50 def on_leave( thing, to):45 def on_leave(self, thing, to): 51 46 for c in each_element('on-leave'): 52 47 command(thing, c, [to]) 53 48 54 def command(s ource, command, arguments):49 def command(self, source, command, arguments): 55 50 if command.action[1]: 56 51 text = command.action[1] -
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')
