Esempio n. 1
0
    def set_item(self,
                 item,
                 slot,
                 count=1,
                 is_swap=False,
                 perm_enchant=0,
                 created_by=None):
        if self.can_set_item(item, slot, is_swap=is_swap):
            if isinstance(item, ItemManager):
                item_mgr = item
                if item_mgr == self:
                    return None
            else:
                item_creator = 0 if not created_by else created_by.guid
                item_mgr = ItemManager.generate_item(item,
                                                     self.owner,
                                                     self.current_slot,
                                                     slot,
                                                     stack_count=count,
                                                     perm_enchant=perm_enchant,
                                                     creator=item_creator)

            if item_mgr:
                item_mgr.current_slot = slot
                self.sorted_slots[slot] = item_mgr
                # Update slot fields.
                if not self.is_backpack:
                    self.build_container_update_packet()

            if item_mgr.item_template.bonding == ItemBondingTypes.BIND_WHEN_PICKED_UP:
                item_mgr.set_binding(True)
            return item_mgr
        return None
Esempio n. 2
0
    def set_item(self, item, slot, count=1):
        if self.can_set_item(item, slot):
            if isinstance(item, ItemManager):
                item_mgr = item
                if item_mgr == self:
                    return None
            else:
                item_mgr = ItemManager.generate_item(item, self.owner, self.current_slot, slot, count=count)

            if item_mgr:
                item_mgr.current_slot = slot
                self.sorted_slots[slot] = item_mgr
                RealmDatabaseManager.character_inventory_update_item(item_mgr.item_instance)

            if item_mgr.item_template.bonding == ItemBondingTypes.BIND_WHEN_PICKED_UP:
                item_mgr.set_binding(True)
            return item_mgr
        return None
Esempio n. 3
0
    def set_item(self, item, slot, count=1):
        if self.can_set_item(item, slot):
            if isinstance(item, ItemManager):
                item_mgr = item
                if item_mgr == self:
                    return None
            else:
                item_mgr = ItemManager.generate_item(item,
                                                     self.owner,
                                                     self.current_slot,
                                                     slot,
                                                     count=count)

            if item_mgr:
                item_mgr.current_slot = slot
                self.sorted_slots[slot] = item_mgr

            return item_mgr
        return None
Esempio n. 4
0
    def set_item(self, item, slot, count=1):
        if self.can_set_item(item, slot):
            if isinstance(item, ItemManager):
                item_mgr = item
                if item_mgr == self:
                    return None
            else:
                item_mgr = ItemManager.generate_item(item,
                                                     self.owner,
                                                     self.current_slot,
                                                     slot,
                                                     count=count)

            if item_mgr:
                item_mgr.current_slot = slot
                self.sorted_slots[slot] = item_mgr
                RealmDatabaseManager.character_inventory_update_item(
                    item_mgr.item_instance)
            return item_mgr
        return None
Esempio n. 5
0
    def set_item(self, item, slot, count=1):
        if not item or len(self.sorted_slots
                           ) == self.total_slots or slot > self.total_slots:
            return None

        if isinstance(item, ItemManager):
            item_mgr = item
            if item_mgr == self:
                return None
        else:
            item_mgr = ItemManager.generate_item(item,
                                                 self.owner,
                                                 self.current_slot,
                                                 slot,
                                                 count=count)
        if item_mgr:
            item_mgr.current_slot = slot
            self.sorted_slots[slot] = item_mgr

        return item_mgr