Changeset 121 for adventure/world.py
- Timestamp:
- 10/24/07 13:27:51 (3 years ago)
- Files:
-
- 1 modified
-
adventure/world.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
adventure/world.py
r119 r121 15 15 doc = xml_parse(filename) 16 16 doc_getAttribute = doc.documentElement.getAttribute 17 self.node = doc .documentElement.getAttribute('node')18 self.name = doc .documentElement.getAttribute('name')19 self.start = doc .documentElement.getAttribute('start')17 self.node = doc_getAttribute('node') 18 self.name = doc_getAttribute('name') 19 self.start = doc_getAttribute('start') 20 20 get_elements = doc.documentElement.getElementsByTagName 21 21 places = get_elements('place') 22 22 for place in places: 23 place_obj = Place(place.getAttribute('name'), 24 place.getAttribute('description')) 23 place_obj = Place( 24 place.getAttribute('name'), 25 place.getElementsByTagName('description')[0].firstChild.data) 25 26 self.places[place_obj.name] = place_obj 26 27 gos = place.getElementsByTagName('go') … … 30 31 #things = get_elements('thing') 31 32 #for thing in things: 32 33 33 34 34 35 … … 106 107 msg.setType('normal') 107 108 msg.setSubject('Adventure component help') 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()) 109 msg.setBody('You don\'t need to subscribe to my presence. ' 110 'Simply use your Jabber client to join the MUC or ' 111 'conference at %s' % pres.getTo()) 109 112 self.send(None, msg) 110 113 return True … … 113 116 player = None 114 117 for thing in self.things.values(): 115 if isinstance(thing, Player) and pres.getTo().getResource() == thing.name: 118 if (isinstance(thing, Player) and 119 pres.getTo().getResource() == thing.name): 116 120 player = thing 117 121 118 122 # Disallow nick changes 119 if isinstance(thing, Player) and (pres.getFrom() == thing.jid) and (player != thing): 120 answer = Error(pres, 'not-acceptable', 'Nickchange not allowed') #False 123 if (isinstance(thing, Player) and pres.getFrom() == thing.jid and 124 player != thing): 125 answer = Error(pres, 'not-acceptable', 126 'Nickchange not allowed') #False 121 127 self.send(thing.name, answer) 122 128 return True 123 129 124 130 # Either nick-collission or empty nick 125 if player and pres.getFrom() != player.jid or len(pres.getTo().getResource()) < 2: 131 if (player and pres.getFrom() != player.jid or 132 len(pres.getTo().getResource()) < 2): 126 133 answer = None 127 134 if len(pres.getTo().getResource()) > 1: … … 138 145 self.things[player.name] = player 139 146 self.move_thing(player, self.start) 140 player.send_message('Help!', 'Send "?" to get a list of available commands any time.') 147 player.send_message('Help!', 'Send "?" to get a list of available ' 148 'commands any time.') 141 149 # Or broadcast updated presence 142 150 else: … … 158 166 player = None 159 167 for thing in self.things.values(): 160 if isinstance(thing, Player) and not msg.getTo().getResource() and msg.getFrom() == thing.jid: 168 if (isinstance(thing, Player) and not msg.getTo().getResource() and 169 msg.getFrom() == thing.jid): 161 170 player = thing 162 171 … … 172 181 def command(self, player, text): 173 182 if text == '?': 174 player.send_message( None, '(Command) who')183 player.send_message('Help!', '(Command) who') 175 184 place = self.place(player.place) 176 185 if place: 177 186 for exit_name in place.exits.keys(): 178 player.send_message( None, '(Command) go %s' % exit_name)187 player.send_message('Help!', '(Command) go %s' % exit_name) 179 188 for thing in self.each_thing_by_place(player.place): 180 189 for c in thing.actions: 181 player.send_message(None, '(Command) %s %s' % (c.expressions[0], thing.name)) 190 player.send_message('Help!', 191 '(Command) %s %s' % (c.expressions[0], 192 thing.name)) 182 193 return True 183 194 else: … … 189 200 what = '' 190 201 if cmd == 'go': 202 print what 191 203 oldplace = self.place(player.place) 192 204 newplace = None … … 205 217 for thing in self.things.values(): 206 218 if isinstance(thing, Player): 207 player.send_message(None, '%s is at/in %s' % (thing.name, thing.place)) 219 player.send_message(None, 220 '%s is at/in %s' % (thing.name, 221 thing.place)) 208 222 return True 209 223 else:
