コード例 #1
0
    def links(self):
        """
        Generate a link to the location that this exit points at.

        @return: an iterator which yields a single L{Link}, annotated with a
            L{Vector} that indicates a distance of 1.0 (a temporary measure,
            since L{Exit}s don't have distances yet) and a direction of this
            exit's C{name}.
        """
        l = Link(self.exitIdea, self.toLocation.idea)
        l.annotate([Vector(self.distance, self.name),
                    # We annotate this link with ourselves because the 'Named'
                    # retriever will use the last link in the path to determine
                    # if an object has any aliases.  We want this direction
                    # name to be an alias for the room itself as well as the
                    # exit, so we want to annotate the link with an INameable.
                    # This also has an effect of annotating the link with an
                    # IExit, and possibly one day an IItem as well (if such a
                    # thing ever comes to exist), so perhaps we eventually want
                    # a wrapper which elides all references here except
                    # INameable since that's what we want.  proxyForInterface
                    # perhaps?  However, for the moment, the extra annotations
                    # do no harm, so we'll leave them there.
                    self])
        yield l
コード例 #2
0
ファイル: objects.py プロジェクト: jerith/imaginary
    def links(self):
        """
        Generate a link to the location that this exit points at.

        @return: an iterator which yields a single L{Link}, annotated with a
            L{Vector} that indicates a distance of 1.0 (a temporary measure,
            since L{Exit}s don't have distances yet) and a direction of this
            exit's C{name}.
        """
        l = Link(self.exitIdea, self.toLocation.idea)
        l.annotate([Vector(self.distance, self.name),
                    # We annotate this link with ourselves because the 'Named'
                    # retriever will use the last link in the path to determine
                    # if an object has any aliases.  We want this direction
                    # name to be an alias for the room itself as well as the
                    # exit, so we want to annotate the link with an INameable.
                    # This also has an effect of annotating the link with an
                    # IExit, and possibly one day an IItem as well (if such a
                    # thing ever comes to exist), so perhaps we eventually want
                    # a wrapper which elides all references here except
                    # INameable since that's what we want.  proxyForInterface
                    # perhaps?  However, for the moment, the extra annotations
                    # do no harm, so we'll leave them there.
                    self])
        yield l
コード例 #3
0
ファイル: glass.py プロジェクト: ashfall/imaginary
 def links(self):
     """
     If the container attached to this L{GlassBox}'s C{thing} is closed,
     yield its list of contents with each link annotated with
     L{_ObstructedByGlass}, indicating that the object cannot be reached.
     """
     container = IContainer(self.thing)
     if container.closed:
         for content in container.getContents():
             link = Link(self.thing.idea, content.idea)
             link.annotate([_ObstructedByGlass(),
                            ContainmentRelationship(container)])
             yield link
コード例 #4
0
ファイル: glass.py プロジェクト: zeeneddie/imaginary
 def links(self):
     """
     If the container attached to this L{GlassBox}'s C{thing} is closed,
     yield its list of contents with each link annotated with
     L{_ObstructedByGlass}, indicating that the object cannot be reached.
     """
     container = IContainer(self.thing)
     if container.closed:
         for content in container.getContents():
             link = Link(self.thing.idea, content.idea)
             link.annotate([_ObstructedByGlass(),
                            ContainmentRelationship(container,
                                                    content)])
             yield link
コード例 #5
0
ファイル: objects.py プロジェクト: jerith/imaginary
 def links(self):
     """
     Implement L{ILinkContributor} to contribute L{Link}s to all contents of
     this container, as well as all of its exits, and its entrance from its
     location.
     """
     if not self.closed:
         for ob in self.getContents():
             content = Link(self.thing.idea, ob.idea)
             content.annotate([ContainmentRelationship(self)])
             yield content
     yield Link(self.thing.idea, self._entranceIdea)
     yield Link(self.thing.idea, self._exitIdea)
     for exit in self.getExits():
         yield Link(self.thing.idea, exit.exitIdea)
コード例 #6
0
 def links(self):
     """
     Implement L{ILinkContributor} to contribute L{Link}s to all contents of
     this container, as well as all of its exits, and its entrance from its
     location.
     """
     if not self.closed:
         for ob in self.getContents():
             content = Link(self.thing.idea, ob.idea)
             content.annotate([ContainmentRelationship(self, ob)])
             yield content
     yield Link(self.thing.idea, self._entranceIdea)
     if self.thing.location is not None:
         yield Link(self.thing.idea, self._exitIdea)
     for exit in self.getExits():
         yield Link(self.thing.idea, exit.exitIdea)
コード例 #7
0
ファイル: objects.py プロジェクト: jerith/imaginary
 def links(self):
     """
     Implement L{ILinkContributor.links()} by offering a link to this
     L{Thing}'s C{location} (if it has one).
     """
     # since my link contribution is to go up (out), put this last, since
     # containment (i.e. going down (in)) is a powerup.  we want to explore
     # contained items first.
     for pup in self.powerupsFor(iimaginary.ILinkContributor):
         for link in pup.links():
             # wooo composition
             yield link
     if self.location is not None:
         l = Link(self.idea, self.location.idea)
         # XXX this incorrectly identifies any container with an object in
         # it as 'here', since it doesn't distinguish the observer; however,
         # cycle detection will prevent these links from being considered in
         # any case I can think of.  However, 'here' is ambiguous in the
         # case where you are present inside a container, and that should
         # probably be dealt with.
         l.annotate([AlsoKnownAs('here')])
         yield l
コード例 #8
0
 def links(self):
     """
     Implement L{ILinkContributor.links()} by offering a link to this
     L{Thing}'s C{location} (if it has one).
     """
     # since my link contribution is to go up (out), put this last, since
     # containment (i.e. going down (in)) is a powerup.  we want to explore
     # contained items first.
     for pup in self.powerupsFor(iimaginary.ILinkContributor):
         for link in pup.links():
             # wooo composition
             yield link
     if self.location is not None:
         l = Link(self.idea, self.location.idea)
         # XXX this incorrectly identifies any container with an object in
         # it as 'here', since it doesn't distinguish the observer; however,
         # cycle detection will prevent these links from being considered in
         # any case I can think of.  However, 'here' is ambiguous in the
         # case where you are present inside a container, and that should
         # probably be dealt with.
         l.annotate([AlsoKnownAs('here')])
         yield l