Changeset 114

Show
Ignore:
Timestamp:
10/14/07 17:08:42 (3 years ago)
Author:
elghinn
Message:
 
Location:
adventure
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • adventure/adventuremuc.py

    r112 r114  
    3232    def send(self, worldnode, worldresource, stanza): 
    3333        stanza.setFrom(JID(node=worldnode, domain=self.jid.domain, resource=worldresource)) 
    34         self.send(stanza) 
     34        Component.send(self, stanza) 
    3535 
    36     def handle_iq(self, iq): 
     36    def handle_iq(self, _, iq): 
    3737        #print "iq: from #{iq.from} type #{iq.type} to #{iq.to}: #{iq.queryns}" 
    3838 
     
    8787    #    self.component.send(answer) 
    8888 
    89     def handle_presence(self, pres): 
     89    def handle_presence(self, _, pres): 
    9090        print 'presence: from %s type %s to %s' % (pres.getFrom(), pres.getType(), pres.getTo()) 
    9191     
    92         world = self.worlds[pres.to.node] 
     92        world = self.worlds[pres.getTo().getNode()] 
    9393        if not world: 
    94             answer = pres.answer 
     94            answer = pres.buildReply() 
    9595            answer.setType('error') 
    9696            #answer.add(Jabber::Error.new('item-not-found', 'The world you are trying to reach is currently unavailable.')) 
    9797            self.component.send(answer) 
    9898        else: 
    99             world.handle_presence(pres) 
     99            world.handle_presence(self,pres) 
    100100        return True 
    101101 
    102     def handle_message(msg): 
     102    def handle_message(self, _, msg): 
    103103        print 'message: from %s type %s to %s: %s' % (msg.getFrom(), msg.getType(), msg.getTo(), repr(msg.getBody())) 
    104104 
  • adventure/player.py

    r108 r114  
    2222 
    2323    def send_message(self, fromresource, text, subject=None): 
    24         msg = Message(jid, text) 
     24        msg = Message(self.jid, text) 
    2525        msg.setType('groupchat') 
    2626        if subject: 
  • adventure/thing.py

    r109 r114  
    1414        self.UID = 0 
    1515        self.place = None 
    16          
    17     def command_name(self): 
    18         if attributes['command-name']: 
    19             return attributes['command-name'] 
    20         return self.iname() 
    2116 
    22     def jid(): 
     17    def jid(self): 
    2318        return None 
    2419 
    25     def presence(): 
     20    def presence(self): 
    2621        xe = None 
    2722        #for pres in each_element('presence'): 
     
    3328        return xe 
    3429 
    35     def see(place): 
     30    def see(self, place): 
    3631        pass 
    3732 
    38     def send_message(fromresource, text, subject=None): 
     33    def send_message(self, fromresource, text, subject=None): 
    3934        pass 
    4035 
    41     def send_message_to_place(fromresource, text): 
     36    def send_message_to_place(self, fromresource, text): 
    4237        for thing in self.world.each_element('thing'): 
    4338            if thing.place == place: 
    4439                thing.send_message(fromresource, text) 
    4540   
    46     def on_enter(thing, from_): 
     41    def on_enter(self, thing, from_): 
    4742        for c in each_element('on-enter'): 
    4843            command(thing, c, [from_]) 
    4944 
    50     def on_leave(thing, to): 
     45    def on_leave(self, thing, to): 
    5146        for c in each_element('on-leave'): 
    5247            command(thing, c, [to]) 
    5348 
    54     def command(source, command, arguments): 
     49    def command(self, source, command, arguments): 
    5550            if command.action[1]: 
    5651                text = command.action[1] 
  • adventure/world.py

    r112 r114  
    4949 
    5050    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): 
    5252            # Call leave hooks 
    5353            t.on_leave(thing, newplace) 
     
    7373        thing.place = newplace 
    7474 
    75         for t in each_thing_by_place(thing.place): 
     75        for t in self.each_thing_by_place(thing.place): 
    7676            # Broadcast availability presence to enterer 
    7777            if t.presence: 
     
    9595        thing.see(place(newplace)) 
    9696 
    97         for t in each_thing_by_place(thing.place): 
     97        for t in self.each_thing_by_place(thing.place): 
    9898            # Call enter hooks 
    9999            t.on_enter(thing, oldplace) 
    100100 
    101     def handle_presence(pres): 
     101    def handle_presence(self, _, pres): 
    102102        # A help for the irritated first: 
    103103        if pres.getType() == 'subscribe': 
     
    139139            player.presence = pres 
    140140            self.players[player.name] = player 
    141             move_thing(player, attributes['start']) 
     141            self.move_thing(player, self.start) 
    142142            player.send_message('Help!', 'Send "?" to get a list of available commands any time.') 
    143143        # Or broadcast updated presence 
     
    145145            player.presence = pres 
    146146 
    147             for t in each_thing_by_place(player.place): 
     147            for t in self.each_thing_by_place(player.place): 
    148148                # Broadcast presence to all who are here 
    149149                pres = Presence(node=player.presence) 
     
    156156            del self.players[player.name] 
    157157 
    158     def handle_message(msg): 
     158    def handle_message(self, _, msg): 
    159159        player = None 
    160160        for thing in self.things.values(): 
     
    170170 
    171171        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): 
    173173                thing.send_message(player.iname, msg.body) 
    174174 
    175     def command(player, text): 
     175    def command(self, player, text): 
    176176        if text == '?': 
    177177            player.send_message(None, '(Command) who') 
     
    195195                newplace = None 
    196196 
    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 
    200200 
    201201                if newplace: 
    202                     move_thing(player, newplace) 
     202                    self.move_thing(player, newplace) 
    203203                else: 
    204204                    player.send_message(None, 'You cannot go there')