def equipItemRequest(self, itemIndex, equipIndex): if self.inventory.equipItem(itemIndex, equipIndex) == -1: self.client.errorInfo(4) else: #传回去装备和物品信息 itemUUId = self.inventory.getItemUidByIndex(itemIndex) equipUUId = self.inventory.getEquipUidByIndex(equipIndex) itemInfo = TItemInfo() itemInfo.extend([0, 0, 0, itemIndex]) equipItemInfo = TItemInfo() equipItemInfo.extend([0, 0, 0, equipIndex]) if itemUUId != 0: itemInfo = self.itemList[itemUUId] if equipUUId != 0: equipItemInfo = self.equipItemList[equipUUId] self.client.equipItemRequest_re(itemInfo, equipItemInfo) #-------------------- avatarCell = self.cell avatarCell.resetPropertys() for key, info in self.equipItemList.items(): items.getItem(info[1]).use(self) if equipIndex == 0: uid = self.inventory.getEquipUidByIndex(equipIndex) if uid == 0: avatarCell.equipNotify(-1) else: avatarCell.equipNotify(self.equipItemList[uid][1])
def equipItemRequest( self, itemIndex, equipIndex): if self.inventory.equipItem(itemIndex, equipIndex) == -1: self.client.errorInfo(4) else: #传回去装备和物品信息 itemUUId = self.inventory.getItemUidByIndex(itemIndex) equipUUId = self.inventory.getEquipUidByIndex(equipIndex) itemInfo = TItemInfo() itemInfo.extend([0, 0, 0, itemIndex]) equipItemInfo = TItemInfo() equipItemInfo.extend([0, 0, 0, equipIndex]) if itemUUId != 0: itemInfo = self.itemList[itemUUId] if equipUUId != 0: equipItemInfo = self.equipItemList[equipUUId] self.client.equipItemRequest_re(itemInfo,equipItemInfo) #-------------------- avatarCell = self.cell avatarCell.resetPropertys() for key, info in self.equipItemList.items(): items.getItem(info[1]).use(self) if equipIndex == 0: uid = self.inventory.getEquipUidByIndex(equipIndex) if uid == 0: avatarCell.equipNotify(-1) else: avatarCell.equipNotify(self.equipItemList[uid][1])
def addItem(self, itemID, itemCount = 1): if self.isResource(itemID) or self.isMissionItem(itemID): return result = [] emptyIndex = -1 for i in range(0,self.maxBagNum): if self.invIndex2Uids[i] == 0: emptyIndex = i break #背包已经满了 if emptyIndex == -1: return result #放置物品 itemStack = d_items.datas[itemID]['maxnum'] #不可堆叠物品 if itemStack == 1: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemID, 1, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) #可堆叠物品 else: for key, info in self._entity.itemList.items(): if info[1] == itemID and info[2] < itemStack: info[2] += itemCount result.append(key) if info[2] > itemStack: itemCount = info[2]-itemStack info[2] = itemStack else: itemCount = 0 break if itemCount > 0: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemID, itemCount, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) #这里有个bug,当背包里没有此道具,而插入道具数量超过可叠加数量时,会一起放一个格子 return result
def setItemInOuroItemList(self, item, index): itemInfo = TItemInfo() if item == -1: self.invIndex2Uids[index] = -1 for key, info in list(self.currentEntityItemList): if info[3] == index: print('remove it', index) del self.currentEntityItemListInfo[key] else: itemInfo.extend([ item.getUUID(), item.getID(), item.getCount(), item.getIndex() ]) self.invIndex2Uids[item.getIndex()] = item.getUUID() self.currentEntityItemListInfo[item.getUUID()] = itemInfo
def addItem(self, itemId, itemCount=1): result = [] emptyIndex = -1 for i in range(0, 12): if self.invIndex2Uids[i] == 0: emptyIndex = i break #背包已经满了 if emptyIndex == -1: return result #放置物品 itemStack = d_items.datas[itemId]['itemStack'] #不可堆叠物品 if itemStack == 1: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemId, 1, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) #可堆叠物品 else: for key, info in self._entity.itemList.items(): if info[1] == itemId and info[2] < itemStack: info[2] += itemCount result.append(key) if info[2] > itemStack: itemCount = info[2] - itemStack info[2] = itemStack else: itemCount = 0 break if itemCount > 0: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemId, itemCount, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) return result
def addItem(self, itemId, itemCount = 1): result = [] emptyIndex = -1 for i in range(0,12): if self.invIndex2Uids[i] == 0: emptyIndex = i break #背包已经满了 if emptyIndex == -1: return result #放置物品 itemStack = d_items.datas[itemId]['itemStack'] #不可堆叠物品 if itemStack == 1: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemId, 1, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) #可堆叠物品 else: for key, info in self._entity.itemList.items(): if info[1] == itemId and info[2] < itemStack: info[2] += itemCount result.append(key) if info[2] > itemStack: itemCount = info[2]-itemStack info[2] = itemStack else: itemCount = 0 break if itemCount > 0: itemUUID = KBEngine.genUUID64() iteminfo = TItemInfo() iteminfo.extend([itemUUID, itemId, itemCount, emptyIndex]) self.invIndex2Uids[emptyIndex] = itemUUID self._entity.itemList[itemUUID] = iteminfo result.append(itemUUID) return result