def __OverInMaterialSlot(self, trash, resultIndex, col): self.tooltipItem.ClearToolTip() self.tooltipItem.SetCannotUseItemForceSetDisableColor(FALSE) resultIndex = resultIndex + self.firstSlotIndex if resultIndex not in self.cubeMaterialInfos: return i = 0 materialInfo = self.cubeMaterialInfos[resultIndex] materialCount = len(materialInfo[col]) for itemVnum, count in materialInfo[col]: item.SelectItem(itemVnum) if player.GetItemCountByVnum(itemVnum) >= count: self.tooltipItem.AppendTextLine( "%s" % (item.GetItemName()), grp.GenerateColor(0.5411, 0.7254, 0.5568, 1.0)).SetFeather() else: self.tooltipItem.AppendTextLine( "%s" % (item.GetItemName()), grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)).SetFeather() if i < materialCount - 1: self.tooltipItem.AppendTextLine( uiScriptLocale.CUBE_REQUIRE_MATERIAL_OR) i = i + 1 self.tooltipItem.Show()
def __OnSelectMaterialSlot(self, trash, resultIndex, materialIndex): resultIndex = resultIndex + self.firstSlotIndex if resultIndex not in self.cubeMaterialInfos: return materialInfo = self.cubeMaterialInfos[resultIndex] materialCount = len(materialInfo[materialIndex]) if 0 == materialCount: return for itemVnum, itemCount in materialInfo[materialIndex]: bAddedNow = FALSE # 이번에 클릭함으로써 아이템이 추가되었나? item.SelectItem(itemVnum) itemSizeX, itemSizeY = item.GetItemSize() # 제조에 필요한 만큼의 재료를 가지고 있는가? if player.GetItemCountByVnum(itemVnum) >= itemCount: for i in xrange(player.INVENTORY_SLOT_COUNT): vnum = player.GetItemIndex(i) count = player.GetItemCount(i) if vnum == itemVnum and count >= itemCount: # 이미 같은 아이템이 등록되어 있는지 검사하고, 없다면 추가함 bAlreadyExists = FALSE for slotPos, invenPos in self.cubeItemInfo.items(): if invenPos == i: bAlreadyExists = TRUE if TRUE == bAlreadyExists: continue #continue inventory iterating #print "Cube Status : ", self.cubeItemInfo # 여기 진입하면 큐브에 등록되지 않은 아이템이므로, 빈 큐브 슬롯에 해당 아이템 추가 bCanAddSlot = FALSE for slotPos in xrange(self.cubeSlot.GetSlotCount()): # 이 큐브 슬롯이 비어있는가? if not slotPos in self.cubeItemInfo: upperColumnItemSizeY = -1 currentSlotLine = int(slotPos / self.CUBE_SLOT_COUNTX) cubeColumn = int(slotPos % self.CUBE_SLOT_COUNTX) # 만약 큐브에 3칸짜리 아이템이 등록되어 있다면, 이 열(column)은 더 이상 볼 것도 없이 넘어간다 if cubeColumn in self.cubeItemInfo: columnVNUM = player.GetItemIndex( self.cubeItemInfo[cubeColumn]) item.SelectItem(columnVNUM) columnItemSizeX, columnItemSizeY = item.GetItemSize( ) if 3 == columnItemSizeY: continue #continue cube slot iterating if 0 < currentSlotLine and slotPos - self.CUBE_SLOT_COUNTX in self.cubeItemInfo: upperColumnVNUM = player.GetItemIndex( self.cubeItemInfo[ slotPos - self.CUBE_SLOT_COUNTX]) item.SelectItem(upperColumnVNUM) columnItemSizeX, upperColumnItemSizeY = item.GetItemSize( ) # 1칸짜리 아이템은 바로 윗줄에 한칸짜리 아이템이 있어야 함 if 1 == itemSizeY: if 0 == currentSlotLine: bCanAddSlot = TRUE elif 1 == currentSlotLine and 1 == upperColumnItemSizeY: bCanAddSlot = TRUE elif 2 == currentSlotLine: bCanAddSlot = TRUE # 2칸짜리 아이템은 위아래가 비어있어야 함 elif 2 == itemSizeY: if 0 == currentSlotLine and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo: bCanAddSlot = TRUE elif 1 == currentSlotLine and 1 == upperColumnItemSizeY and not cubeColumn + ( self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo: bCanAddSlot = TRUE # 3칸짜리 아이템은 해당 Column 자체가 모두 비어있어야 함 else: if not cubeColumn in self.cubeItemInfo and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo and not cubeColumn + ( self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo: bCanAddSlot = TRUE if TRUE == bCanAddSlot: self.cubeItemInfo[slotPos] = i self.cubeSlot.SetItemSlot( slotPos, vnum, count) net.SendChatPacket("/cube add %d %d" % (slotPos, i)) bAddedNow = TRUE if TRUE == bAddedNow: break #break cube slot iterating if TRUE == bAddedNow: break #break inventory iterating if TRUE == bAddedNow: break #break material iterating
def __OnSelectMaterialSlot(self, trash, resultIndex, materialIndex): resultIndex = resultIndex + self.firstSlotIndex if resultIndex not in self.cubeMaterialInfos: return materialInfo = self.cubeMaterialInfos[resultIndex] materialCount = len(materialInfo[materialIndex]) if 0 == materialCount: return for itemVnum, itemCount in materialInfo[materialIndex]: bAddedNow = False item.SelectItem(itemVnum) itemSizeX, itemSizeY = item.GetItemSize() if player.GetItemCountByVnum(itemVnum) >= itemCount: for i in xrange(player.INVENTORY_SLOT_COUNT): vnum = player.GetItemIndex(i) count = player.GetItemCount(i) if vnum == itemVnum and count >= itemCount: bAlreadyExists = False for slotPos, invenPos in self.cubeItemInfo.items(): if invenPos == i: bAlreadyExists = True if True == bAlreadyExists: continue #continue inventory iterating #print "Cube Status : ", self.cubeItemInfo bCanAddSlot = False for slotPos in xrange(self.cubeSlot.GetSlotCount()): if not slotPos in self.cubeItemInfo: upperColumnItemSizeY = -1 currentSlotLine = int(slotPos / self.CUBE_SLOT_COUNTX) cubeColumn = int(slotPos % self.CUBE_SLOT_COUNTX) if cubeColumn in self.cubeItemInfo: columnVNUM = player.GetItemIndex( self.cubeItemInfo[cubeColumn]) item.SelectItem(columnVNUM) columnItemSizeX, columnItemSizeY = item.GetItemSize( ) if 3 == columnItemSizeY: continue #continue cube slot iterating if 0 < currentSlotLine and slotPos - self.CUBE_SLOT_COUNTX in self.cubeItemInfo: upperColumnVNUM = player.GetItemIndex( self.cubeItemInfo[ slotPos - self.CUBE_SLOT_COUNTX]) item.SelectItem(upperColumnVNUM) columnItemSizeX, upperColumnItemSizeY = item.GetItemSize( ) if 1 == itemSizeY: if 0 == currentSlotLine: bCanAddSlot = True elif 1 == currentSlotLine and 1 == upperColumnItemSizeY: bCanAddSlot = True elif 2 == currentSlotLine: bCanAddSlot = True elif 2 == itemSizeY: if 0 == currentSlotLine and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo: bCanAddSlot = True elif 1 == currentSlotLine and 1 == upperColumnItemSizeY and not cubeColumn + ( self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo: bCanAddSlot = True else: if not cubeColumn in self.cubeItemInfo and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo and not cubeColumn + ( self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo: bCanAddSlot = True if True == bCanAddSlot: self.cubeItemInfo[slotPos] = i self.cubeSlot.SetItemSlot( slotPos, vnum, count) net.SendChatPacket("/cube add %d %d" % (slotPos, i)) bAddedNow = True if True == bAddedNow: break #break cube slot iterating if True == bAddedNow: break #break inventory iterating if True == bAddedNow: break #break material iterating