Changeset 119
Legend:
- Unmodified
- Added
- Removed
-
adventure/thing.py
r118 r119 14 14 self.UID = 0 15 15 self.place = None 16 self.on_enter = list() 17 self.on_leave = list() 16 18 17 19 def jid(self): … … 40 42 41 43 def on_enter(self, thing, from_): 42 for c in each_element('on-enter'):43 command(thing, c, [from_])44 for c in self.on_enter: 45 self.command(thing, c, [from_]) 44 46 45 47 def on_leave(self, thing, to): 46 for c in each_element('on-leave'):47 command(thing, c, [to])48 for c in self.on_leave: 49 self.command(thing, c, [to]) 48 50 49 51 def command(self, source, command, arguments): … … 69 71 sender = self.name 70 72 if command.action[3] == 'all': 71 se nd_message_to_place(sender, text)73 self.send_message_to_place(sender, text) 72 74 else: 73 75 source.send_message(sender, text) -
adventure/world.py
r118 r119 19 19 self.start = doc.documentElement.getAttribute('start') 20 20 get_elements = doc.documentElement.getElementsByTagName 21 places = get_elements('place s')21 places = get_elements('place') 22 22 for place in places: 23 23 place_obj = Place(place.getAttribute('name'), … … 44 44 45 45 def each_thing_by_place(self, placename): 46 for thing in self.things.values(): 47 if thing.place == placename: 48 yield(thing) 46 if placename: 47 for thing in self.things.values(): 48 if thing.place == placename: 49 yield(thing) 49 50 50 51 def move_thing(self, thing, newplace): … … 105 106 msg.setType('normal') 106 107 msg.setSubject('Adventure component help') 107 msg.setBody =('You don\'t need to subscribe to my presence. Simply use your Jabber client to join the MUC or conference at %s' % pres.getTo())108 msg.setBody('You don\'t need to subscribe to my presence. Simply use your Jabber client to join the MUC or conference at %s' % pres.getTo()) 108 109 self.send(None, msg) 109 110 return True … … 144 145 for t in self.each_thing_by_place(player.place): 145 146 # Broadcast presence to all who are here 146 pres = Presence(node=player.presence) 147 pres.to = t.jid 148 self.send(player.name, pres) 147 if isinstance(t, Player): 148 pres = Presence(node=player.presence) 149 pres.setTo(t.jid) 150 self.send(player.name, pres) 149 151 150 152 # Remove the player instantly … … 156 158 player = None 157 159 for thing in self.things.values(): 158 print msg.getFrom(), thing.jid159 160 if isinstance(thing, Player) and not msg.getTo().getResource() and msg.getFrom() == thing.jid: 160 161 player = thing … … 188 189 what = '' 189 190 if cmd == 'go': 190 oldplace = place(player.place)191 oldplace = self.place(player.place) 191 192 newplace = None 192 193
