示例#1
0
文件: __init__.py 项目: abliss/stark
 def get_from_container(self):
     # get the container
     containers = find_actionable_item(self.anima, self.tokens[1])
     
     if not containers:
         return "No such item: %s" % self.tokens[1]
     elif not containers[0].base.capacity:
         return "%s is not a container" % self.tokens[1]
     
     # get the item from the first found container
     # TODO: decide what to do about multiple containers here
     items = find_items_in_container(self.tokens[0],
                                     containers[0].owns.all())
     if not items:
         return "No '%s' found in '%s'" % (self.tokens[0], self.tokens[1])
     
     return self._get_items_in(items, source=containers[0].get_name())
示例#2
0
文件: __init__.py 项目: abliss/stark
    def _execute(self):
        # get the items that the user wants to put somewhere
        items = find_items_in_container(self.tokens[0],
                                        self.anima.inventory)
        if not items:
            return ("You are not carrying a '%s'" % self.tokens[0])
        
        # find the container
        containers = find_actionable_item(self.anima, self.tokens[1])

        if not containers:
            return "No such item: %s" % self.tokens[1]
        elif not containers[0].base.capacity:
            return "%s is not a container" % self.tokens[1]
            
        room_msg = []
        source_msg = []
        for item in items:
            # weight check
            if can_hold_item(containers[0], item):
                item.owner = containers[0]
                item.save()
                room_msg.append("%s puts %s in %s." % (
                                    self.anima.get_name(),
                                    item.get_name(),
                                    containers[0].get_name(),
                                ))
                source_msg.append("You put %s in %s." %
                              (item.get_name(), containers[0].get_name()))
                item.owner = containers[0]
                item.save()
            else:
                source_msg.append("%s cannot fit inside %s."
                                  % self.tokens[0:1])

        self.anima.room.notify('\n'.join(room_msg), exclude=[self.anima])
        return '\n'.join(source_msg), ['player', 'room']