Changeset 119

Show
Ignore:
Timestamp:
10/15/07 20:43:34 (2 years ago)
Author:
elghinn
Message:

et encore moins de bugs

Location:
adventure
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • adventure/thing.py

    r118 r119  
    1414        self.UID = 0 
    1515        self.place = None 
     16        self.on_enter = list() 
     17        self.on_leave = list() 
    1618 
    1719    def jid(self): 
     
    4042   
    4143    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_]) 
    4446 
    4547    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]) 
    4850 
    4951    def command(self, source, command, arguments): 
     
    6971                    sender = self.name 
    7072                if command.action[3] == 'all': 
    71                     send_message_to_place(sender, text) 
     73                    self.send_message_to_place(sender, text) 
    7274                else: 
    7375                    source.send_message(sender, text) 
  • adventure/world.py

    r118 r119  
    1919        self.start = doc.documentElement.getAttribute('start') 
    2020        get_elements = doc.documentElement.getElementsByTagName 
    21         places = get_elements('places') 
     21        places = get_elements('place') 
    2222        for place in places: 
    2323            place_obj = Place(place.getAttribute('name'), 
     
    4444 
    4545    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) 
    4950 
    5051    def move_thing(self, thing, newplace): 
     
    105106            msg.setType('normal') 
    106107            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()) 
    108109            self.send(None, msg) 
    109110            return True 
     
    144145            for t in self.each_thing_by_place(player.place): 
    145146                # 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) 
    149151     
    150152        # Remove the player instantly 
     
    156158        player = None 
    157159        for thing in self.things.values(): 
    158             print msg.getFrom(), thing.jid 
    159160            if isinstance(thing, Player) and not msg.getTo().getResource() and msg.getFrom() == thing.jid: 
    160161                player = thing 
     
    188189                what = '' 
    189190            if cmd == 'go': 
    190                 oldplace = place(player.place) 
     191                oldplace = self.place(player.place) 
    191192                newplace = None 
    192193