Ejemplo n.º 1
0
    def do(self, caller, thing):
        r = "%s's variables:\n" % thing
        keys = thing.__dict__.keys()
        keys.sort()
        for key in keys:
            if type(thing.__dict__[key]) == DictType:
                text = "  %s:\n" % key
                for key2, value2 in thing.__dict__[key].items():
                    text += "    %s: %s\n" % (key2, value2)
            else:
                text = "  %s: %s\n" % (key, thing.__dict__[key])
            r += text

        r += "\n%s's methods:\n" % thing
        # Inheritance says we have to look in class and
        # base classes; order is not important.
        # returns all methods, not just of TextControl class
        classes = [thing.__class__]
        all_methods = []

        for aclass in self._get_classes(thing):
            if aclass.__bases__:
                r += "  class: %s\n" % aclass
                my_methods = []
                for m in dir(aclass):
                    if m[:1] != "_":
                        if m not in all_methods:
                            my_methods.append(m)
                            all_methods.append(m)
                if my_methods:
                    my_methods.sort()
                    r += PrettyOutput().columnize(my_methods, indent=4)

        self.sendEvent(evt.TextMessage(r), caller)
Ejemplo n.º 2
0
    def do(self, caller, where, what):
        if what in where:
            r = "True"
        else:
            r = "False"

        self.sendEvent(evt.TextMessage(r), caller)
Ejemplo n.º 3
0
    def on_look(self, event):
        r = self.shortDescription
        if len(self.gear) > 0:
            r = r + "\n%s carries:\n" % self
            for slot in self.gear:
                r = r + "%s\n" % slot

        self.sendEvent(evt.TextMessage(r), event.viewer)
Ejemplo n.º 4
0
    def on_look(self, event):
        if len(self.text) > 0:
            r = self.text
        else:
            r = "empty"

        response = evt.TextMessage(r)
        self.sendEvent(response, event.sender)
Ejemplo n.º 5
0
Archivo: base.py Proyecto: bitcraft/mud
 def sendEvent(self, event, sendTo=None):
     if self.isDestroyed:
         if self.control:
             msg = evt.TextMessage("you are dead")
             evt.EventClient.sendEvent(self, msg, self.control)
     else:
         if sendTo == None:
             if self.location == None:
                 return
             sendTo = self.location
         evt.EventClient.sendEvent(self, event, sendTo)
Ejemplo n.º 6
0
    def open_state(self, isOpen):
        if isOpen == self.isOpen:
            return

        mc.RoomExit.open_state(self, isOpen)

        if self.isNoisey and self.isOpen:
            self.sendEvent(evt.TextMessage("ding!"), self.location.channel)
        if self.isOpen:
            self.emote(text="slides open.")
        else:
            self.emote(text="slides closed.")
Ejemplo n.º 7
0
    def on_look(self, event):
        r = self.shortDescription
        if len(self) > 0:
            if self.isOpen:
                r = r + "\nContains:\n"
                for thing in self:
                    r = r + "\t%s\n" % thing
            else:
                r = r + "\nclosed."
        else:
            r = "\nis empty"

        self.sendEvent(evt.TextMessage(r), event.viewer)
Ejemplo n.º 8
0
Archivo: base.py Proyecto: bitcraft/mud
 def on_look(self, event):
     response = evt.TextMessage(self.shortDescription)
     self.sendEvent(response, event.viewer)
Ejemplo n.º 9
0
 def on_look(self, event):
     contents = self.list_contents(event.viewer)
     text = "%s\n\n%s" % (self.longDescription, contents)
     print "sent: text"
     self.sendEvent(evt.TextMessage(text), event.viewer)
Ejemplo n.º 10
0
 def on_look(self, event):
     panel = self.generate_panel()
     contents = self.list_contents(event.viewer)
     text = "%s\n\n%s\n%s" % (self.longDescription, panel, contents)
     self.sendEvent(evt.TextMessage(text), event.viewer)
Ejemplo n.º 11
0
 def arrive(self, floor):
     self.onFloor = floor
     self.exitDoor.exitsTo = self.floors[floor]
     self.exitDoor.pair(self.doors[floor])
     self.sendEvent(evt.TextMessage("arrived %s." % floor), self.channel)
     self.openDoor()