示例#1
0
    def remove_bag(self, slot):
        slot = InventorySlots(slot)
        if not self.is_bag_pos(slot) or not self.containers[slot]:
            return False

        if slot in self.get_backpack().sorted_slots:
            self.get_backpack().sorted_slots.pop(slot)
        self.containers[slot] = None

        return True
示例#2
0
    def add_bag(self, slot, container):
        slot = InventorySlots(slot)
        if not self.is_bag_pos(slot):
            return False

        if slot in self.get_backpack().sorted_slots and self.get_backpack().sorted_slots[slot] != container:
            self.get_backpack().sorted_slots[slot] = container
        self.containers[slot] = container

        # Update items' bag slot field
        for item in self.containers[slot].sorted_slots.values():
            item.item_instance.bag = slot.value
        return True