Changeset 121 for adventure/world.py

Show
Ignore:
Timestamp:
10/24/07 13:27:51 (3 years ago)
Author:
elghinn
Message:

* no more bugs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • adventure/world.py

    r119 r121  
    1515        doc = xml_parse(filename) 
    1616        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') 
    2020        get_elements = doc.documentElement.getElementsByTagName 
    2121        places = get_elements('place') 
    2222        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) 
    2526            self.places[place_obj.name] = place_obj 
    2627            gos = place.getElementsByTagName('go') 
     
    3031        #things = get_elements('thing') 
    3132        #for thing in things: 
    32              
     33 
    3334 
    3435 
     
    106107            msg.setType('normal') 
    107108            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()) 
    109112            self.send(None, msg) 
    110113            return True 
     
    113116        player = None 
    114117        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): 
    116120                player = thing 
    117121 
    118122            # 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 
    121127                self.send(thing.name, answer) 
    122128                return True 
    123129 
    124130        # 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): 
    126133            answer = None 
    127134            if len(pres.getTo().getResource()) > 1: 
     
    138145            self.things[player.name] = player 
    139146            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.') 
    141149        # Or broadcast updated presence 
    142150        else: 
     
    158166        player = None 
    159167        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): 
    161170                player = thing 
    162171 
     
    172181    def command(self, player, text): 
    173182        if text == '?': 
    174             player.send_message(None, '(Command) who') 
     183            player.send_message('Help!', '(Command) who') 
    175184            place = self.place(player.place) 
    176185            if place: 
    177186                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) 
    179188            for thing in self.each_thing_by_place(player.place): 
    180189                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)) 
    182193            return True 
    183194        else: 
     
    189200                what = '' 
    190201            if cmd == 'go': 
     202                print what 
    191203                oldplace = self.place(player.place) 
    192204                newplace = None 
     
    205217                for thing in self.things.values(): 
    206218                    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)) 
    208222                return True 
    209223            else: