def AcceptInputPrice(self):

        if not self.priceInputBoard:
            return True

        text = self.priceInputBoard.GetText()

        if not text:
            return True

        if not text.isdigit():
            return True

        if int(text) <= 0:
            return True

        attachedInvenType = self.priceInputBoard.sourceWindowType
        sourceSlotPos = self.priceInputBoard.sourceSlotPos
        targetSlotPos = self.priceInputBoard.targetSlotPos

        for privatePos, (itemWindowType,
                         itemSlotIndex) in self.itemStock.items():
            if itemWindowType == attachedInvenType and itemSlotIndex == sourceSlotPos:
                shop.DelPrivateShopItemStock(itemWindowType, itemSlotIndex)
                del self.itemStock[privatePos]

        price = int(self.priceInputBoard.GetText())

        if IsPrivateShopItemPriceList():
            SetPrivateShopItemPrice(self.priceInputBoard.itemVNum, price)

        shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos,
                                     targetSlotPos, price)
        count = player.GetItemCount(attachedInvenType, sourceSlotPos)
        vnum = player.GetItemIndex(attachedInvenType, sourceSlotPos)
        self.SaveFilePrice(vnum, count, price)
        self.itemStock[targetSlotPos] = (attachedInvenType, sourceSlotPos)
        snd.PlaySound("sound/ui/drop.wav")

        self.Refresh()

        #####

        self.priceInputBoard = None
        return True
Example #2
0
    def __OnSelectEmptySlot(self, selectedSlotPos):
        isAttached = mouseModule.mouseController.isAttached()
        if isAttached:
            attachedSlotType = mouseModule.mouseController.GetAttachedType()
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            targetIndex = player.GetItemIndex(attachedSlotPos)
            if attachedSlotType != player.SLOT_TYPE_INVENTORY:
                return

            mouseModule.mouseController.DeattachObject()

            item.SelectItem(targetIndex)
            itemType = item.GetItemType()
            itemSubType = item.GetItemSubType()
            itemVnum = player.GetItemIndex(attachedSlotPos)
            if itemType != item.ITEM_TYPE_COSTUME:
                chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT3)
                return

            if app.ENABLE_SASH_SYSTEM:
                if itemSubType == item.COSTUME_TYPE_SASH:
                    chat.AppendChat(
                        chat.CHAT_TYPE_INFO,
                        "<Support System> You can not put this item!")
                    return

            if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE):
                chat.AppendChat(
                    chat.CHAT_TYPE_INFO,
                    "<Support System> You can not put this item. Your support is male!"
                )
                return

            self.combSlot.SetItemSlot(selectedSlotPos,
                                      player.GetItemIndex(attachedSlotPos),
                                      player.GetItemCount(attachedSlotPos))

            if selectedSlotPos == 1:
                net.SendChatPacket("/support_system %s" % (str(itemVnum)))
            else:
                net.SendChatPacket("/support_system_d %s" % (str(itemVnum)))

            for i in xrange(4):
                self.combSlot.ClearSlot(i)
    def OnSelectEmptySlot(self, selectedSlotPos):

        isAttached = mouseModule.mouseController.isAttached()
        if isAttached:
            attachedSlotType = mouseModule.mouseController.GetAttachedType()
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            mouseModule.mouseController.DeattachObject()

            if player.SLOT_TYPE_INVENTORY != attachedSlotType and player.SLOT_TYPE_DRAGON_SOUL_INVENTORY != attachedSlotType:
                return
            attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
            count = player.GetItemCount(attachedInvenType, attachedSlotPos)

            itemVNum = player.GetItemIndex(attachedInvenType, attachedSlotPos)
            item.SelectItem(itemVNum)

            if item.IsAntiFlag(item.ANTIFLAG_GIVE) or item.IsAntiFlag(
                    item.ANTIFLAG_MYSHOP):
                chat.AppendChat(chat.CHAT_TYPE_INFO,
                                localeInfo.PRIVATE_SHOP_CANNOT_SELL_ITEM)
                return

            priceInputBoard = uiCommon.MoneyInputDialog()

            priceInputBoard.SetTitle(
                localeInfo.PRIVATE_SHOP_INPUT_PRICE_DIALOG_TITLE)
            priceInputBoard.SetAcceptEvent(
                ui.__mem_func__(self.AcceptInputPrice))
            priceInputBoard.SetCancelEvent(
                ui.__mem_func__(self.CancelInputPrice))
            priceInputBoard.SetMaxLength(16)
            priceInputBoard.Open()

            itemPrice = self.ReadFilePrice(itemVNum, count)

            if itemPrice > 0:
                priceInputBoard.SetValue(itemPrice)

            self.priceInputBoard = priceInputBoard
            self.priceInputBoard.itemVNum = itemVNum
            self.priceInputBoard.sourceWindowType = attachedInvenType
            self.priceInputBoard.sourceSlotPos = attachedSlotPos
            self.priceInputBoard.targetSlotPos = selectedSlotPos
Example #4
0
    def SetItemPrice(self, slot):
        _id = player.GetItemIndex(slot)
        if _id == 0:
            return

        str_price = self.items_ui[_id]['item_price'].GetText()

        if self.MultiplicationButton.isOn:
            won, yang = OpenLib.ConvertPrice(str_price,
                                             player.GetItemCount(slot))
        else:
            won, yang = OpenLib.ConvertPrice(str_price, 1)

        #Ignore items with price at 0
        if won + yang <= 0.9:
            return

        shop.AddPrivateShopItemStock(player.SLOT_TYPE_INVENTORY, slot, slot,
                                     yang, won)
	def SelectEmptySlot(self, selectedSlotPos):
		if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
			return

		selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(player.DRAGON_SOUL_INVENTORY, selectedSlotPos)
		print "__debug", selectedSlotPos
		if mouseModule.mouseController.isAttached():

			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
			attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()

			attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
			if player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
				mouseModule.mouseController.RunCallBack("INVENTORY")

			elif player.SLOT_TYPE_SHOP == attachedSlotType:
				net.SendShopBuyPacket(attachedSlotPos)

			elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
				if player.ITEM_MONEY == attachedItemIndex:
					net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
					snd.PlaySound("sound/ui/money.wav")

				else:
					net.SendSafeboxCheckoutPacket(attachedSlotPos, player.DRAGON_SOUL_INVENTORY, selectedSlotPos)

			elif player.SLOT_TYPE_MALL == attachedSlotType:
				net.SendMallCheckoutPacket(attachedSlotPos, player.DRAGON_SOUL_INVENTORY, selectedSlotPos)

			elif player.RESERVED_WINDOW != attachedInvenType:
				if player.IsDSEquipmentSlot(attachedInvenType, attachedSlotPos):
					srcItemPos = (attachedInvenType, attachedSlotPos)
					dstItemPos = (player.DRAGON_SOUL_INVENTORY, selectedSlotPos)
					self.__OpenQuestionDialog(FALSE, srcItemPos, dstItemPos)
				else:
					itemCount = player.GetItemCount(attachedInvenType, attachedSlotPos)
					attachedCount = mouseModule.mouseController.GetAttachedItemCount()
 
					self.__SendMoveItemPacket(attachedInvenType, attachedSlotPos, player.DRAGON_SOUL_INVENTORY, selectedSlotPos, attachedCount)

			mouseModule.mouseController.DeattachObject()
Example #6
0
    def RefreshSlot(self):
        getItemVNum = player.GetItemIndex

        for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
            slotNumber = item.BELT_INVENTORY_SLOT_START + i
            self.wndBeltInventorySlot.SetItemSlot(
                slotNumber, getItemVNum(slotNumber),
                player.GetItemCount(slotNumber))
            self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(
                slotNumber, TRUE)

            avail = "0"

            if player.IsAvailableBeltInventoryCell(slotNumber):
                self.wndBeltInventorySlot.EnableCoverButton(slotNumber)
            else:
                self.wndBeltInventorySlot.DisableCoverButton(slotNumber)

        self.wndBeltInventorySlot.RefreshSlot()
Example #7
0
    def AcceptInputPrice(self):

        if not self.priceInputBoard:
            return True

        text = self.priceInputBoard.GetText()

        if not text:
            return True

        if not text.isdigit():
            return True

        if int(text) <= 0:
            return True

        attachedInvenType = self.priceInputBoard.sourceWindowType
        sourceSlotPos = self.priceInputBoard.sourceSlotPos
        targetSlotPos = self.priceInputBoard.targetSlotPos
        price = int(self.priceInputBoard.GetText())
        count = player.GetItemCount(attachedInvenType, sourceSlotPos)
        vnum = player.GetItemIndex(attachedInvenType, sourceSlotPos)
        self.items[int(targetSlotPos)] = {
            "vnum": int(vnum),
            "count": int(count),
            "price": int(price),
            "sourceSlot": sourceSlotPos,
            "sourceWindow": attachedInvenType
        }
        snd.PlaySound("sound/ui/pick.wav")
        #self.ItemSlot.DeactivateSlot(targetSlotPos)
        net.SendChatPacket(
            "/update_shop_item add|%d|%d|%d|%d|%s" %
            (int(self.id), int(targetSlotPos), int(sourceSlotPos),
             int(attachedInvenType), str(price)))
        self.Refresh()

        #####

        self.priceInputBoard = None
        return True
Example #8
0
    def __SellItem(self, itemSlotPos):
        if not player.IsEquipmentSlot(itemSlotPos):
            self.sellingSlotNumber = itemSlotPos
            itemIndex = player.GetItemIndex(itemSlotPos)
            itemCount = player.GetItemCount(itemSlotPos)

            self.sellingSlotitemIndex = itemIndex
            self.sellingSlotitemCount = itemCount

            item.SelectItem(itemIndex)
            ## 안티 플레그 검사 빠져서 추가
            ## 20140220
            if item.IsAntiFlag(item.ANTIFLAG_SELL):
                popup = uiCommon.PopupDialog()
                popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
                popup.SetAcceptEvent(self.__OnClosePopupDialog)
                popup.Open()
                self.popup = popup
                return

            itemPrice = item.GetISellItemPrice()

            if item.Is1GoldItem():
                itemPrice = itemCount / itemPrice / 5
            else:
                itemPrice = itemPrice * itemCount / 5

            item.GetItemName(itemIndex)
            itemName = item.GetItemName()

            self.questionDialog = uiCommon.QuestionDialog()
            self.questionDialog.SetText(
                localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
            self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
            self.questionDialog.SetCancelEvent(
                ui.__mem_func__(self.OnCloseQuestionDialog))
            self.questionDialog.Open()
            self.questionDialog.count = itemCount

            constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
Example #9
0
	def SelectEmptySlot(self, selectedSlotPos):
		if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
			return

		selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)

		if mouseModule.mouseController.isAttached():

			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
			attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()

			if player.SLOT_TYPE_INVENTORY == attachedSlotType:
				itemCount = player.GetItemCount(attachedSlotPos)
				attachedCount = mouseModule.mouseController.GetAttachedItemCount()
				self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)

				if item.IsRefineScroll(attachedItemIndex):
					self.wndItem.SetUseMode(FALSE)

			elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
				mouseModule.mouseController.RunCallBack("INVENTORY")

			elif player.SLOT_TYPE_SHOP == attachedSlotType:
				net.SendShopBuyPacket(attachedSlotPos)

			elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:

				if player.ITEM_MONEY == attachedItemIndex:
					net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
					snd.PlaySound("sound/ui/money.wav")

				else:
					net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)

			elif player.SLOT_TYPE_MALL == attachedSlotType:
				net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)

			mouseModule.mouseController.DeattachObject()
Example #10
0
    def __OnSelectEmptySlot(self, selectedSlotPos):
        isAttached = mouseModule.mouseController.isAttached()
        if isAttached:
            attachedSlotType = mouseModule.mouseController.GetAttachedType()
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            mouseModule.mouseController.DeattachObject()
            if player.SLOT_TYPE_INVENTORY != attachedSlotType:
                return

            if constInfo.IS_ACCE_ITEM(player.GetItemIndex(attachedSlotPos),
                                      0) == TRUE:
                if selectedSlotPos == 1 and self.slot_pos_index == 999:
                    return

                if self.slot_index1 == attachedSlotPos and selectedSlotPos == 0 or self.slot_index2 == attachedSlotPos and selectedSlotPos == 1:
                    return
                elif self.slot_index2 == attachedSlotPos and selectedSlotPos == 0 or self.slot_index1 == attachedSlotPos and selectedSlotPos == 1:
                    return

                if selectedSlotPos == 0:
                    self.slot_index1 = attachedSlotPos
                elif selectedSlotPos == 1:
                    self.slot_index2 = attachedSlotPos

                for slotPos, invenPos in self.acceItemInfo.items():
                    if invenPos == attachedSlotPos:
                        del self.acceItemInfo[slotPos]

                self.acceItemInfo[selectedSlotPos] = attachedSlotPos
                self.slot_pos_index = attachedSlotPos
                self.acceSlot.ClearSlot(selectedSlotPos)
                self.acceSlot.SetItemSlot(selectedSlotPos,
                                          player.GetItemIndex(attachedSlotPos),
                                          player.GetItemCount(attachedSlotPos))
                net.SendChatPacket("/acce add %d %d" %
                                   (selectedSlotPos, attachedSlotPos))

            self.Refresh()
	def SelectItemSlot(self, itemSlotIndex):
		if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
			return

		itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(player.DRAGON_SOUL_INVENTORY, itemSlotIndex)

		if mouseModule.mouseController.isAttached():
			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
				
			attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
			if player.RESERVED_WINDOW != attachedInvenType:
				net.SendItemUseToItemPacket(attachedInvenType, attachedSlotPos, player.DRAGON_SOUL_INVENTORY, itemSlotIndex)

			mouseModule.mouseController.DeattachObject()

		else:
			selectedItemVNum = player.GetItemIndex(player.DRAGON_SOUL_INVENTORY, itemSlotIndex)
			itemCount = player.GetItemCount(player.DRAGON_SOUL_INVENTORY, itemSlotIndex)
			mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_DRAGON_SOUL_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
			self.wndItem.SetUseMode(FALSE)
			snd.PlaySound("sound/ui/pick.wav")
Example #12
0
	def __SellItem(self, itemSlotPos):
		if not player.IsEquipmentSlot(itemSlotPos):
			self.sellingSlotNumber = itemSlotPos
			itemIndex = player.GetItemIndex(itemSlotPos)
			itemCount = player.GetItemCount(itemSlotPos)

			item.SelectItem(itemIndex)
			itemPrice = item.GetISellItemPrice()

			if item.Is1GoldItem():
				itemPrice = itemCount / itemPrice / 5
			else:
				itemPrice = itemPrice * itemCount / 5

			item.GetItemName(itemIndex)
			itemName = item.GetItemName()

			self.questionDialog = uiCommon.QuestionDialog()
			self.questionDialog.SetText(locale.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
			self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
			self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
			self.questionDialog.Open()
			self.questionDialog.count = itemCount
	def __RefreshRefineItemSlot(self):
		try:
			for slotPos in xrange(self.wndRefineSlot.GetSlotCount()):
				self.wndRefineSlot.ClearSlot(slotPos)
				if slotPos < self.refineSlotLockStartIndex:
					# self.refineItemInfo[slotPos]의 정보확인
					# (실제로 아이템이 존재하는지 확인)
					# 존재 -> 아이템 아이콘을 슬롯에 셋팅.
					# 비존재 -> 아이템이 없으므로 강화창에서 삭제.
					if slotPos in self.refineItemInfo:
						invenType, invenPos, itemCount = self.refineItemInfo[slotPos]
						itemVnum = player.GetItemIndex(invenType, invenPos)

						# if itemVnum:
						if itemVnum:
							self.wndRefineSlot.SetItemSlot(slotPos, player.GetItemIndex(invenType, invenPos), itemCount)
						else:
							del self.refineItemInfo[slotPos]

					# 빈 슬롯에 reference 아이콘을 alpha 0.5로 셋팅.
					if not slotPos in self.refineItemInfo:
						try:
							reference_vnum = 0
							# strength 강화일 때는,
							# 0번 슬롯에 강화석을, 1번 슬롯에 용혼석을 놓는다.
							if DragonSoulRefineWindow.REFINE_TYPE_STRENGTH == self.currentRefineType:
								if DragonSoulRefineWindow.REFINE_STONE_SLOT == slotPos:
									reference_vnum = 100300
							else:
								reference_vnum = self.__MakeDragonSoulVnum(*self.currentRecipe["ds_info"])
							if 0 != reference_vnum:
								item.SelectItem(reference_vnum)
								itemIcon = item.GetIconImage()
								(width, height) = item.GetItemSize()
								self.wndRefineSlot.SetSlot(slotPos, 0, width, height, itemIcon, (1.0, 1.0, 1.0, 0.5))
								# slot 우측 하단에 숫자 뜨면 안 예쁨...
								self.wndRefineSlot.SetSlotCount(slotPos, 0)
						except:
							pass
					# refineSlotLockStartIndex 보다 작은 슬롯은 닫힌 이미지를 보여주면 안됨.
					self.wndRefineSlot.HideSlotBaseImage(slotPos)
				# slotPos >= self.refineSlotLockStartIndex:
				else:
					# 정상적인 경우라면 이 if문에 들어갈 일은 없겠지만,
					# (애초에 인덱스가 refineSlotLockStartIndex 이상인 슬롯에는 아이템을 넣지 못하게 했기 때문)
					# 혹시 모를 에러에 대비함.
					if slotPos in self.refineItemInfo:
						invenType, invenPos, itemCount = self.refineItemInfo[slotPos]
						remainCount = player.GetItemCount(invenType, invenPos)
						player.SetItemCount(invenType, invenPos, remainCount + itemCount)
						del self.refineItemInfo[selectedSlotPos]
					# refineSlotLockStartIndex 이상인 슬롯은 닫힌 이미지를 보여줘야함.
					self.wndRefineSlot.ShowSlotBaseImage(slotPos)
			
			# 강화창에 아무런 아이템이 없다면, 초기화해줌.
			# 위에서 중간 중간에 "del self.refineItemInfo[slotPos]"를 했기 때문에,
			# 여기서 한번 체크해줘야함.
			if not self.refineItemInfo:
				self.__Initialize()
 
			self.wndRefineSlot.RefreshSlot()
		except Exception, e:
			import dbg
			dbg.TraceError("Exception : __RefreshRefineItemSlot, %s" % e)
Example #14
0
	def RefreshQuickSlot(self):

		pageNum = player.GetQuickPage()

		try:
			self.quickPageNumImageBox.LoadImage(TaskBar.QUICKPAGE_NUMBER_FILENAME[pageNum])
		except:
			pass

		startNumber = 0
		for slot in self.quickslot:

			for i in xrange(4):

				slotNumber = i+startNumber

				(Type, Position) = player.GetLocalQuickSlot(slotNumber)

				if player.SLOT_TYPE_NONE == Type:
					slot.ClearSlot(slotNumber)
					continue

				if player.SLOT_TYPE_INVENTORY == Type:

					itemIndex = player.GetItemIndex(Position)
					itemCount = player.GetItemCount(Position)
					if itemCount <= 1:
						itemCount = 0

					## 자동물약 (#72723, #72724) 특수처리 - 아이템인데도 슬롯에 활성화/비활성화 표시를 위한 작업임 - [hyo]
					if constInfo.IS_AUTO_POTION(itemIndex):
						# metinSocket - [0] : 활성화 여부, [1] : 사용한 양, [2] : 최대 용량
						metinSocket = [player.GetItemMetinSocket(Position, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]

						if 0 != int(metinSocket[0]):
							slot.ActivateSlot(slotNumber)
						else:
							slot.DeactivateSlot(slotNumber)

					slot.SetItemSlot(slotNumber, itemIndex, itemCount)

				elif player.SLOT_TYPE_SKILL == Type:

					skillIndex = player.GetSkillIndex(Position)
					if 0 == skillIndex:
						slot.ClearSlot(slotNumber)
						continue

					skillType = skill.GetSkillType(skillIndex)
					if skill.SKILL_TYPE_GUILD == skillType:
						import guild
						skillGrade = 0
						skillLevel = guild.GetSkillLevel(Position)

					else:
						skillGrade = player.GetSkillGrade(Position)
						skillLevel = player.GetSkillLevel(Position)

					slot.SetSkillSlotNew(slotNumber, skillIndex, skillGrade, skillLevel)
					slot.SetSlotCountNew(slotNumber, skillGrade, skillLevel)
					slot.SetCoverButton(slotNumber)

					## NOTE : CoolTime 체크
					if player.IsSkillCoolTime(Position):
						(coolTime, elapsedTime) = player.GetSkillCoolTime(Position)
						slot.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)

					## NOTE : Activate 되어 있다면 아이콘도 업데이트
					if player.IsSkillActive(Position):
						slot.ActivateSlot(slotNumber)

				elif player.SLOT_TYPE_EMOTION == Type:

					emotionIndex = Position
					slot.SetEmotionSlot(slotNumber, emotionIndex)
					slot.SetCoverButton(slotNumber)
					slot.SetSlotCount(slotNumber, 0)

			slot.RefreshSlot()
			startNumber += 4
Example #15
0
    def __OnSelectItemSlot(self, selectedSlotPos):
        if selectedSlotPos == 2:
            return

        snd.PlaySound("sound/ui/loginfail.wav")
        self.acceSlot.ClearSlot(selectedSlotPos)
        net.SendChatPacket("/acce del %d " % selectedSlotPos)
        if selectedSlotPos == 0:
            self.slot_pos_index = 999
            self.slot_index1 = 999
            self.acceSlot.ClearSlot(1)
            net.SendChatPacket("/acce del %d " % 1)
            self.slot_index2 = 999
            self.acceSlot.ClearSlot(2)
        elif selectedSlotPos == 1:
            self.slot_index1 = 999
            self.acceSlot.ClearSlot(0)
            self.slot_index2 = 999
            self.acceSlot.ClearSlot(2)
            net.SendChatPacket("/acce del %d " % 0)

        if not selectedSlotPos in self.acceItemInfo:
            return

        del self.acceItemInfo[selectedSlotPos]

        isAttached = mouseModule.mouseController.isAttached()
        if isAttached:
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            if constInfo.IS_ACCE_ITEM(player.GetItemIndex(attachedSlotPos),
                                      1) == TRUE:
                if selectedSlotPos == 2:
                    return

                if selectedSlotPos == 0:
                    self.slot_pos_index = attachedSlotPos

                if self.slot_index1 == attachedSlotPos and selectedSlotPos == 0 or self.slot_index2 == attachedSlotPos and selectedSlotPos == 1:
                    return
                elif self.slot_index2 == attachedSlotPos and selectedSlotPos == 0 or self.slot_index1 == attachedSlotPos and selectedSlotPos == 1:
                    return

                if selectedSlotPos == 0:
                    self.slot_index1 = attachedSlotPos
                elif selectedSlotPos == 1:
                    self.slot_index2 = attachedSlotPos

                for slotPos, invenPos in self.acceItemInfo.items():
                    if invenPos == attachedSlotPos:
                        del self.acceItemInfo[slotPos]

                self.acceItemInfo[selectedSlotPos] = attachedSlotPos
                self.acceSlot.ClearSlot(selectedSlotPos)
                self.acceSlot.SetItemSlot(selectedSlotPos,
                                          player.GetItemIndex(attachedSlotPos),
                                          player.GetItemCount(attachedSlotPos))
                net.SendChatPacket("/acce add %d %d" %
                                   (selectedSlotPos, attachedSlotPos))
                if selectedSlotPos == 1:
                    self.acceSlot.SetItemSlot(
                        2, player.GetItemIndex(self.slot_index1),
                        player.GetItemCount(self.slot_index1))

            mouseModule.mouseController.DeattachObject()

        self.Refresh()
Example #16
0
    def SelectItemSlot(self, itemSlotIndex):
        if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
            return

        itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(
            itemSlotIndex)

        if mouseModule.mouseController.isAttached():
            attachedSlotType = mouseModule.mouseController.GetAttachedType()
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex(
            )

            if player.SLOT_TYPE_INVENTORY == attachedSlotType:
                self.__DropSrcItemToDestItemInInventory(
                    attachedItemVID, attachedSlotPos, itemSlotIndex)

            mouseModule.mouseController.DeattachObject()

        else:

            curCursorNum = app.GetCursor()
            if app.SELL == curCursorNum:
                self.__SellItem(itemSlotIndex)

            elif app.BUY == curCursorNum:
                chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)

            elif app.IsPressed(app.DIK_LALT):
                link = player.GetItemLink(itemSlotIndex)
                ime.PasteString(link)

            elif app.IsPressed(app.DIK_LSHIFT):
                itemCount = player.GetItemCount(itemSlotIndex)

                if itemCount > 1:
                    self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
                    self.dlgPickMoney.SetAcceptEvent(
                        ui.__mem_func__(self.OnPickItem))
                    self.dlgPickMoney.Open(itemCount)
                    self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
                #else:
                #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
                #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)

            elif app.IsPressed(app.DIK_LCONTROL):
                itemIndex = player.GetItemIndex(itemSlotIndex)

                if TRUE == item.CanAddToQuickSlotItem(itemIndex):
                    player.RequestAddToEmptyLocalQuickSlot(
                        player.SLOT_TYPE_INVENTORY, itemSlotIndex)
                else:
                    chat.AppendChat(chat.CHAT_TYPE_INFO,
                                    localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)

            else:
                selectedItemVNum = player.GetItemIndex(itemSlotIndex)
                itemCount = player.GetItemCount(itemSlotIndex)
                mouseModule.mouseController.AttachObject(
                    self, player.SLOT_TYPE_INVENTORY, itemSlotIndex,
                    selectedItemVNum, itemCount)

                if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
                    self.wndItem.SetUseMode(TRUE)
                else:
                    self.wndItem.SetUseMode(FALSE)

                snd.PlaySound("sound/ui/pick.wav")
Example #17
0
    def RefreshQuickSlot(self):

        pageNum = player.GetQuickPage()

        try:
            self.quickPageNumImageBox.LoadImage(
                TaskBar.QUICKPAGE_NUMBER_FILENAME[pageNum])
        except:
            pass

        startNumber = 0
        for slot in self.quickslot:

            for i in xrange(4):

                slotNumber = i + startNumber

                (Type, Position) = player.GetLocalQuickSlot(slotNumber)

                if player.SLOT_TYPE_NONE == Type:
                    slot.ClearSlot(slotNumber)
                    continue

                if player.SLOT_TYPE_INVENTORY == Type:

                    itemIndex = player.GetItemIndex(Position)
                    itemCount = player.GetItemCount(Position)
                    if itemCount <= 1:
                        itemCount = 0

                    if constInfo.IS_AUTO_POTION(itemIndex):
                        metinSocket = [
                            player.GetItemMetinSocket(Position, j)
                            for j in xrange(player.METIN_SOCKET_MAX_NUM)
                        ]

                        if 0 != int(metinSocket[0]):
                            slot.ActivateSlot(slotNumber)
                        else:
                            slot.DeactivateSlot(slotNumber)

                    if app.ENABLE_GROWTH_PET_SYSTEM:
                        if constInfo.IS_PET_ITEM(itemIndex):
                            self.__SetCoolTimePetItemSlot(
                                slot, Position, slotNumber, itemIndex)

                            slot.DeactivateSlot(slotNumber)

                            active_id = player.GetActivePetItemId()
                            if active_id and active_id == player.GetItemMetinSocket(
                                    Position, 2):
                                slot.ActivateSlot(slotNumber)

                    slot.SetItemSlot(slotNumber, itemIndex, itemCount)

                elif player.SLOT_TYPE_SKILL == Type:

                    skillIndex = player.GetSkillIndex(Position)
                    if 0 == skillIndex:
                        slot.ClearSlot(slotNumber)
                        continue

                    skillType = skill.GetSkillType(skillIndex)
                    if skill.SKILL_TYPE_GUILD == skillType:
                        import guild
                        skillGrade = 0
                        skillLevel = guild.GetSkillLevel(Position)

                    else:
                        skillGrade = player.GetSkillGrade(Position)
                        skillLevel = player.GetSkillLevel(Position)

                    slot.SetSkillSlotNew(slotNumber, skillIndex, skillGrade,
                                         skillLevel)
                    slot.SetSlotCountNew(slotNumber, skillGrade, skillLevel)
                    slot.SetCoverButton(slotNumber)

                    if player.IsSkillCoolTime(Position):
                        (coolTime,
                         elapsedTime) = player.GetSkillCoolTime(Position)
                        slot.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)

                    if player.IsSkillActive(Position):
                        slot.ActivateSlot(slotNumber)

                elif player.SLOT_TYPE_EMOTION == Type:

                    emotionIndex = Position
                    slot.SetEmotionSlot(slotNumber, emotionIndex)
                    slot.SetCoverButton(slotNumber)
                    slot.SetSlotCount(slotNumber, 0)

            slot.RefreshSlot()
            startNumber += 4
Example #18
0
	def __OnSelectEmptySlot(self, selectedSlotPos):
		isAttached = mouseModule.mouseController.isAttached()
		if isAttached:
			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			targetIndex = player.GetItemIndex(attachedSlotPos)

			if attachedSlotType != player.SLOT_TYPE_INVENTORY or player.IsEquipmentSlot(attachedSlotPos):
				return

			if selectedSlotPos == 0:
				item.SelectItem(targetIndex)
				if item.GetItemType() == item.ITEM_TYPE_TRANSFER_SCROLL:
					if self.def_mediumSlot != 999:
						self.mediumSlot.ClearSlot(0)
						self.def_mediumSlot = 999
					
					self.mediumSlot.SetItemSlot(0, player.GetItemIndex(attachedSlotPos), player.GetItemCount(attachedSlotPos))
					net.SendChatPacket("/attrtransfer add %d %d" % (0, attachedSlotPos))

					self.ItemCombBackgroundImage.Show()
					self.combSlot.Show()

					self.def_mediumSlot = selectedSlotPos
					
					for slotPos, invenPos in self.itemInfo.items():
						if invenPos == attachedSlotPos:
							del self.itemInfo[slotPos]
					
					self.itemInfo[selectedSlotPos] = attachedSlotPos
				
					if app.ENABLE_SLOT_MARKING_SYSTEM:
						self.CantTradableItem(selectedSlotPos, attachedSlotPos)
						self.interface.SetOnTopWindow(player.ON_TOP_WND_ATTR_TRANSFER_PHASE2)
						self.interface.RefreshMarkInventoryBag()
				
				mouseModule.mouseController.DeattachObject()
			else:
				mouseModule.mouseController.DeattachObject()
				if self.def_mediumSlot == 999:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT1)
					return
				
				if self.def_combSlot_1 == 999 and selectedSlotPos == 2:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT2)
					return
				
				if selectedSlotPos == 3:
					return
				
				item.SelectItem(targetIndex)
				itemType = item.GetItemType()
				itemSubType = item.GetItemSubType()
				if itemType != item.ITEM_TYPE_COSTUME:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT3)
					return
				
				if ATTR_TRANSFER_LIMIT == 1:
					if not itemSubType in (item.COSTUME_TYPE_BODY, item.COSTUME_TYPE_HAIR, item.COSTUME_TYPE_ACCE):
						chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT4)
						return
				else:
					if itemSubType != item.COSTUME_TYPE_BODY:
						chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT5)
						return
				
				if selectedSlotPos == 2 and self.def_combSlot_1 == attachedSlotPos:
					return
				
				has_attr = 0
				check_attrSlot = [player.GetItemAttribute(player.INVENTORY, attachedSlotPos, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
				if check_attrSlot != 0:
					for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
						type = check_attrSlot[i][0]
						value = check_attrSlot[i][1]
						if type > 0 and value > 0:
							has_attr = 1
							break
				
				if not has_attr:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT6)
					return
				
				if ATTR_TRANSFER_LIMIT == 1 and selectedSlotPos == 2:
					item.SelectItem(player.GetItemIndex(self.def_combSlot_1))
					Costume_1_SubType = item.GetItemSubType()
					if Costume_1_SubType != itemSubType:
						chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.COMB_ALERT4)
						return
				
				self.combSlot.SetItemSlot(selectedSlotPos, player.GetItemIndex(attachedSlotPos), player.GetItemCount(attachedSlotPos))
				net.SendChatPacket("/attrtransfer add %d %d" % (selectedSlotPos, attachedSlotPos))
				if selectedSlotPos == 1:
					self.def_combSlot_1 = attachedSlotPos
				elif selectedSlotPos == 2:
					self.def_combSlot_2 = attachedSlotPos
				
				for slotPos, invenPos in self.itemInfo.items():
					if invenPos == attachedSlotPos:
						del self.itemInfo[slotPos]
				
				self.itemInfo[selectedSlotPos] = attachedSlotPos
				if selectedSlotPos == 2:
					self.combSlot.SetItemSlot(3, player.GetItemIndex(self.def_combSlot_1), 1)

				if app.ENABLE_SLOT_MARKING_SYSTEM:
					self.CantTradableItem(selectedSlotPos, attachedSlotPos)
Example #19
0
	def RefreshOpen(self):
		self.slot.SetItemSlot(self.slotpos, player.GetItemIndex(self.pos), player.GetItemCount(self.pos))
		if player.GetItemCount(self.pos) == 0:
			self.__OnLimpiar()
Example #20
0
    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 __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
		"대상 아이템에 사용할 수 있는가?"

		if srcSlotPos == dstSlotPos:
			return False
			
		if app.ENABLE_ACHIEVEMENT:
			if item.IsAchievementColor(srcItemVNum):
				item.SelectItem(player.GetItemIndex(dstSlotPos))
				if item.GetItemType() == item.ITEM_TYPE_ACHIEVEMENT and item.GetItemSubType() == item.ACHIEVEMENT_TITLE:
					return True	

		if srcItemVNum == player.GetItemIndex(dstSlotPos):
			if player.GetItemCount(dstSlotPos) < 200:
				return True	
		elif item.IsRefineScroll(srcItemVNum):
			if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
				return True
		elif item.IsMetin(srcItemVNum):
			if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
				return True
		elif item.IsDetachScroll(srcItemVNum):
			if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
				return True
		elif item.IsKey(srcItemVNum):
			if player.CanUnlock(srcItemVNum, dstSlotPos):
				return True

		elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
			return True

		else:
			useType=item.GetUseType(srcItemVNum)

			if "USE_CLEAN_SOCKET" == useType:
				if self.__CanCleanBrokenMetinStone(dstSlotPos):
					return True
			elif "USE_CHANGE_ATTRIBUTE" == useType:
				if self.__CanChangeItemAttrList(dstSlotPos):
					return True
			elif "USE_ADD_ATTRIBUTE" == useType:
				if self.__CanAddItemAttr(dstSlotPos):
					return True
			elif "USE_ADD_ATTRIBUTE2" == useType:
				if self.__CanAddItemAttr(dstSlotPos):
					return True
			elif "USE_ADD_ACCESSORY_SOCKET" == useType:
				if self.__CanAddAccessorySocket(dstSlotPos):
					return True
			elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:								
				if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
					return TRUE;
			elif "USE_PUT_INTO_BELT_SOCKET" == useType:								
				dstItemVNum = player.GetItemIndex(dstSlotPos)
				print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum

				item.SelectItem(dstItemVNum)
		
				if item.ITEM_TYPE_BELT == item.GetItemType():
					return True

		return False
Example #22
0
    def __OnSelectEmptySlot(self, selectedSlotPos):
        isAttached = mouseModule.mouseController.isAttached()
        if isAttached:
            attachedSlotType = mouseModule.mouseController.GetAttachedType()
            attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber(
            )
            targetIndex = player.GetItemIndex(attachedSlotPos)
            if attachedSlotType != player.SLOT_TYPE_INVENTORY:
                return

            if selectedSlotPos == 0:
                item.SelectItem(targetIndex)
                if item.GetItemType() == item.ITEM_TYPE_TRANSFER_SCROLL:
                    if self.def_mediumSlot != 999:
                        self.mediumSlot.ClearSlot(0)
                        self.def_mediumSlot = 999

                    self.mediumSlot.SetItemSlot(
                        0, player.GetItemIndex(attachedSlotPos),
                        player.GetItemCount(attachedSlotPos))
                    net.SendChatPacket("/attrtransfer add %d %d" %
                                       (0, attachedSlotPos))
                    self.def_mediumSlot = selectedSlotPos

                    for slotPos, invenPos in self.itemInfo.items():
                        if invenPos == attachedSlotPos:
                            del self.itemInfo[slotPos]

                    self.itemInfo[selectedSlotPos] = attachedSlotPos

                mouseModule.mouseController.DeattachObject()
            else:
                mouseModule.mouseController.DeattachObject()
                if self.def_mediumSlot == 999:
                    chat.AppendChat(chat.CHAT_TYPE_INFO,
                                    localeInfo.COMB_ALERT1)
                    return

                if self.def_combSlot_1 == 999 and selectedSlotPos == 2:
                    chat.AppendChat(chat.CHAT_TYPE_INFO,
                                    localeInfo.COMB_ALERT2)
                    return

                item.SelectItem(targetIndex)
                itemType = item.GetItemType()
                itemSubType = item.GetItemSubType()
                if itemType != item.ITEM_TYPE_COSTUME:
                    chat.AppendChat(chat.CHAT_TYPE_INFO,
                                    localeInfo.COMB_ALERT3)
                    return

                if ATTR_TRANSFER_LIMIT == 1:
                    if not itemSubType in (item.COSTUME_TYPE_BODY,
                                           item.COSTUME_TYPE_HAIR,
                                           item.COSTUME_TYPE_ACCE):
                        chat.AppendChat(chat.CHAT_TYPE_INFO,
                                        localeInfo.COMB_ALERT4)
                        return
                else:
                    if itemSubType != item.COSTUME_TYPE_BODY:
                        chat.AppendChat(chat.CHAT_TYPE_INFO,
                                        localeInfo.COMB_ALERT5)
                        return

                if ATTR_TRANSFER_LIMIT == 1 and selectedSlotPos == 2:
                    item.SelectItem(player.GetItemIndex(self.def_combSlot_1))
                    Costume_1_SubType = item.GetItemSubType()
                    if Costume_1_SubType != itemSubType:
                        chat.AppendChat(chat.CHAT_TYPE_INFO,
                                        localeInfo.COMB_ALERT6)
                        return

                self.combSlot.SetItemSlot(selectedSlotPos,
                                          player.GetItemIndex(attachedSlotPos),
                                          player.GetItemCount(attachedSlotPos))
                net.SendChatPacket("/attrtransfer add %d %d" %
                                   (selectedSlotPos, attachedSlotPos))
                if selectedSlotPos == 1:
                    self.def_combSlot_1 = attachedSlotPos
                elif selectedSlotPos == 2:
                    self.def_combSlot_2 = attachedSlotPos

                for slotPos, invenPos in self.itemInfo.items():
                    if invenPos == attachedSlotPos:
                        del self.itemInfo[slotPos]

                self.itemInfo[selectedSlotPos] = attachedSlotPos
                if selectedSlotPos == 2:
                    self.combSlot.SetItemSlot(
                        3, player.GetItemIndex(self.def_combSlot_1), 1)
class DragonSoulRefineWindow(ui.ScriptWindow):
	REFINE_TYPE_GRADE, REFINE_TYPE_STEP, REFINE_TYPE_STRENGTH = xrange(3)
	DS_SUB_HEADER_DIC = {
		REFINE_TYPE_GRADE : player.DS_SUB_HEADER_DO_UPGRADE,
		REFINE_TYPE_STEP : player.DS_SUB_HEADER_DO_IMPROVEMENT,
		REFINE_TYPE_STRENGTH : player.DS_SUB_HEADER_DO_REFINE 
	}
	REFINE_STONE_SLOT, DRAGON_SOUL_SLOT = xrange(2)

	INVALID_DRAGON_SOUL_INFO = -1
	
	def __init__(self):
		ui.ScriptWindow.__init__(self)
		self.tooltipItem = None
		self.sellingSlotNumber = -1
		self.isLoaded = 0
		self.refineChoiceButtonDict = None
		self.doRefineButton = None
		self.wndMoney = None
		self.SetWindowName("DragonSoulRefineWindow")
		self.__LoadWindow()
		
	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def Show(self):
		self.__LoadWindow()
		ui.ScriptWindow.Show(self)

	def __LoadWindow(self):
		if self.isLoaded == 1:
			return
		self.isLoaded = 1
		try:
			pyScrLoader = ui.PythonScriptLoader()			
			pyScrLoader.LoadScriptFile(self, "uiscript/dragonsoulrefinewindow.py")

		except:
			import exception
			exception.Abort("dragonsoulrefinewindow.LoadWindow.LoadObject")
		try:
			wndRefineSlot = self.GetChild("RefineSlot")
			wndResultSlot = self.GetChild("ResultSlot")
			self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))			
			self.refineChoiceButtonDict = {
				self.REFINE_TYPE_GRADE	: self.GetChild("GradeButton"),
				self.REFINE_TYPE_STEP: self.GetChild("StepButton"),
				self.REFINE_TYPE_STRENGTH	: self.GetChild("StrengthButton"),
			}
			self.doRefineButton = self.GetChild("DoRefineButton")
			self.wndMoney = self.GetChild("Money_Slot")
		
		except:
			import exception
			exception.Abort("DragonSoulRefineWindow.LoadWindow.BindObject")
		
	
		## Item Slots
		wndRefineSlot.SetOverInItemEvent(ui.__mem_func__(self.__OverInRefineItem))
		wndRefineSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutItem))
		wndRefineSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.__SelectRefineEmptySlot))
		wndRefineSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.__SelectRefineItemSlot))
		wndRefineSlot.SetUseSlotEvent(ui.__mem_func__(self.__SelectRefineItemSlot))
		wndRefineSlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.__SelectRefineItemSlot))
		
		wndResultSlot.SetOverInItemEvent(ui.__mem_func__(self.__OverInResultItem))
		wndResultSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutItem))
		self.wndRefineSlot = wndRefineSlot
		self.wndResultSlot = wndResultSlot
		
		## Button
		self.refineChoiceButtonDict[self.REFINE_TYPE_GRADE].SetToggleDownEvent(self.__ToggleDownGradeButton)
		self.refineChoiceButtonDict[self.REFINE_TYPE_STEP].SetToggleDownEvent(self.__ToggleDownStepButton)
		self.refineChoiceButtonDict[self.REFINE_TYPE_STRENGTH].SetToggleDownEvent(self.__ToggleDownStrengthButton)
		self.refineChoiceButtonDict[self.REFINE_TYPE_GRADE].SetToggleUpEvent(lambda : self.__ToggleUpButton(self.REFINE_TYPE_GRADE))
		self.refineChoiceButtonDict[self.REFINE_TYPE_STEP].SetToggleUpEvent(lambda : self.__ToggleUpButton(self.REFINE_TYPE_STEP))
		self.refineChoiceButtonDict[self.REFINE_TYPE_STRENGTH].SetToggleUpEvent(lambda : self.__ToggleUpButton(self.REFINE_TYPE_STRENGTH))
		self.doRefineButton.SetEvent(self.__PressDoRefineButton)
		
		## Dialog
		self.wndPopupDialog = uiCommon.PopupDialog()
		
		self.currentRefineType = self.REFINE_TYPE_GRADE
		self.refineItemInfo = {}
		self.resultItemInfo = {}
		self.currentRecipe = {}
		
		self.wndMoney.SetText(localeInfo.NumberToMoneyString(0))
		self.refineChoiceButtonDict[self.REFINE_TYPE_GRADE].Down()
		
		self.__Initialize()
		
	def Destroy(self):
		self.ClearDictionary()
		self.tooltipItem = None
		self.wndItem = 0
		self.wndEquip = 0
		self.activateButton = 0
		self.questionDialog = None
		self.mallButton = None
		self.inventoryTab = []
		self.deckTab = []
		self.equipmentTab = []
		self.tabDict = None
		self.tabButtonDict = None
		
	def Close(self):
		if None != self.tooltipItem:
			self.tooltipItem.HideToolTip()
		
		self.__FlushRefineItemSlot()
		player.SendDragonSoulRefine(player.DRAGON_SOUL_REFINE_CLOSE)
 		self.Hide()

 	def Show(self):
 		self.currentRefineType = self.REFINE_TYPE_GRADE
		self.wndMoney.SetText(localeInfo.NumberToMoneyString(0))
		self.refineChoiceButtonDict[self.REFINE_TYPE_GRADE].Down()
		self.refineChoiceButtonDict[self.REFINE_TYPE_STEP].SetUp()
		self.refineChoiceButtonDict[self.REFINE_TYPE_STRENGTH].SetUp()
		
		self.Refresh()
 		
		ui.ScriptWindow.Show(self)

	def SetItemToolTip(self, tooltipItem):
		self.tooltipItem = tooltipItem
	
	# 버튼 눌려 있는 상태를 제외한 모든 강화창 관련 변수들을 초기화.
	def __Initialize(self):
		self.currentRecipe = {}
		self.refineItemInfo = {}
		self.resultItemInfo = {}
		
		if self.REFINE_TYPE_STRENGTH == self.currentRefineType:
			self.refineSlotLockStartIndex = 2
		else:
			self.refineSlotLockStartIndex = 1

		for i in xrange(self.refineSlotLockStartIndex):
			self.wndRefineSlot.HideSlotBaseImage(i)

		self.wndMoney.SetText(localeInfo.NumberToMoneyString(0))

	def __FlushRefineItemSlot(self):
		## Item slot settings
		# 원래 인벤의 아이템 카운트 회복
		for invenType, invenPos, itemCount in self.refineItemInfo.values():
			remainCount = player.GetItemCount(invenType, invenPos)
			player.SetItemCount(invenType, invenPos, remainCount + itemCount)
		self.__Initialize()
	
 	def __ToggleUpButton(self, idx):
 		#if self.REFINE_TYPE_GRADE == self.currentRefineType:
 		self.refineChoiceButtonDict[idx].Down()
 
 	def __ToggleDownGradeButton(self):
 		if self.REFINE_TYPE_GRADE == self.currentRefineType:
 			return
 		self.refineChoiceButtonDict[self.currentRefineType].SetUp()
 		self.currentRefineType = self.REFINE_TYPE_GRADE
 		self.__FlushRefineItemSlot()
		self.Refresh()
 		
 	def __ToggleDownStepButton(self):
 		if self.REFINE_TYPE_STEP == self.currentRefineType:
 			return
 		self.refineChoiceButtonDict[self.currentRefineType].SetUp()
 		self.currentRefineType = self.REFINE_TYPE_STEP
		self.__FlushRefineItemSlot()
		self.Refresh()

 	def __ToggleDownStrengthButton(self):
 		if self.REFINE_TYPE_STRENGTH == self.currentRefineType:
 			return
 		self.refineChoiceButtonDict[self.currentRefineType].SetUp()
 		self.currentRefineType = self.REFINE_TYPE_STRENGTH
 		self.__FlushRefineItemSlot()
 		self.Refresh()

 	def __PopUp(self, message):
		self.wndPopupDialog.SetText(message)
		self.wndPopupDialog.Open()
 	
 	def __SetItem(self, (invenType, invenPos), dstSlotIndex, itemCount):
		
		if dstSlotIndex >= self.refineSlotLockStartIndex:
			return FALSE
			
		itemVnum = player.GetItemIndex(invenType, invenPos)
		maxCount = player.GetItemCount(invenType, invenPos)
		
		if itemCount > maxCount:
			raise Exception, ("Invalid attachedItemCount(%d). (base pos (%d, %d), base itemCount(%d))" % (itemCount, invenType, invenPos, maxCount))
			#return FALSE
		
		# strength 강화일 경우, 0번엔 강화석, 1번엔 용혼석을 놓도록 강제함.
		if DragonSoulRefineWindow.REFINE_TYPE_STRENGTH == self.currentRefineType:
			if self.__IsDragonSoul(itemVnum):
				dstSlotIndex = 1
			else:
				dstSlotIndex = 0
		
		# 빈 슬롯이어야함.
		if dstSlotIndex in self.refineItemInfo:
			return FALSE
			
		# 강화창에 올릴 수 있는 아이템인지 검사.
		if FALSE == self.__CheckCanRefine(itemVnum):
			return FALSE
		
		# 끌어다 놓은 아이템 카운트만큼 원래 자리의 아이템 카운트 감소
		player.SetItemCount(invenType, invenPos, maxCount - itemCount)
		self.refineItemInfo[dstSlotIndex] = (invenType, invenPos, itemCount)
		self.Refresh()

		return TRUE
Example #24
0
    def CheckInv(self):
        fishIds = self.catches.keys()
        useBait = False
        dropFish = False
        wormSlot = -1
        pastSlot = -1

        #Check bait and fish killing
        for i in range(0, OpenLib.MAX_INVENTORY_SIZE):
            id = player.GetItemIndex(i)
            if self.wormID == id:
                wormSlot = i
            if self.pasteID == id:
                pastSlot = i
            if dropFish == False and id in self.hairIDs and self.hairBtn.isOn:
                dropFish = True
                net.SendItemDropPacketNew(i, 200)
                continue

            if id in self.liveFish:
                isAliveFish = True
            else:
                isAliveFish = False
            if id in self.deadFish:
                id -= 30
                isDeadFish = True
            else:
                isDeadFish = False

            if id in self.friedFish:
                id -= 60
                isFryFish = True
            else:
                isFryFish = False

            if id in fishIds:
                fishOptions = self.catches[id]

                if useBait == False and 'buttonBait' in fishOptions.keys(
                ) and fishOptions[
                        'buttonBait'].isOn and not isDeadFish and not isFryFish:
                    net.SendItemUsePacket(i)
                    useBait = True
                    continue
                if 'buttonOpen' in fishOptions.keys() and fishOptions[
                        'buttonOpen'].isOn and not isDeadFish and not isFryFish:
                    net.SendItemUsePacket(i)
                    continue
                if dropFish == False and 'buttonDrop' in fishOptions.keys(
                ) and fishOptions['buttonDrop'].isOn:
                    dropFish = True
                    net.SendItemDropPacketNew(i, player.GetItemCount(i))
                    continue

        #Check if inventory is full
        if OpenLib.isInventoryFull():
            self.GoToShop()
            return False

        #Check if rod is available
        val = OpenLib.isItemTypeOnSlot(item.ITEM_TYPE_ROD, player.EQUIPMENT,
                                       item.EQUIPMENT_WEAPON)
        if val == 0:
            slot = OpenLib.GetItemByType(item.ITEM_TYPE_ROD)
            if slot == -1:
                chat.AppendChat(
                    3, "[Fishing-Bot] No rod available, you need a rod first")
                self.exitFishing()
                return False
            else:
                net.SendItemUsePacket(slot)
                return False
        #Check if rod is ready to level up
        if self.rodBtn.isOn and self.isRodAbleToLevelUp():
            self.state = self.STATE_IMPROVING_ROD
            return False

        #Check for next bait to use
        if useBait == False:
            if wormSlot != -1:
                net.SendItemUsePacket(wormSlot)
                return True
            elif pastSlot != -1:
                net.SendItemUsePacket(pastSlot)
                return True
            else:
                if self.buyWormsBtn.isOn:
                    self.GoToShop()
                    return False
                else:
                    self.exitFishing()
                    chat.AppendChat(3, "[Fishing-Bot] No Worms left.")
                    return False

        return True
Example #25
0
    def Refresh(self):
        for slotPos in xrange(self.cubeSlot.GetSlotCount()):

            if not slotPos in self.cubeItemInfo:
                self.cubeSlot.ClearSlot(slotPos)
                continue

            invenPos = self.cubeItemInfo[slotPos]
            itemCount = player.GetItemCount(invenPos)
            if itemCount > 0:
                self.cubeSlot.SetItemSlot(slotPos,
                                          player.GetItemIndex(invenPos),
                                          itemCount)
            else:
                del self.cubeItemInfo[slotPos]
                self.cubeSlot.ClearSlot(slotPos)

        i = 0
        for itemVnum, count in self.cubeResultInfos[self.firstSlotIndex:]:
            currentSlot = self.resultSlots[i]

            item.SelectItem(itemVnum)

            currentSlot.SetItemSlot(0, itemVnum, count)
            currentSlot.Show()

            # Center Align
            item.SelectItem(itemVnum)
            sizeX, sizeY = item.GetItemSize()
            localX, localY = currentSlot.GetLocalPosition()

            currentSlot.SetSize(self.SLOT_SIZEX, self.SLOT_SIZEY * sizeY)

            adjustLocalY = 0
            if sizeY < 3:
                adjustLocalY = int(32 / sizeY)

            currentSlot.SetPosition(localX, 0 + adjustLocalY)

            i = i + 1
            if 3 <= i:
                break

        #print "self.cubeMaterialInfos : ", self.cubeMaterialInfos
        if self.firstSlotIndex in self.cubeMaterialInfos:
            for i in xrange(self.RESULT_SLOT_COUNT):
                materialList = self.cubeMaterialInfos[self.firstSlotIndex + i]
                #print "Refresh ::: ", materialList
                j = 0
                for materialInfo in materialList:
                    if 0 < len(materialInfo):
                        currentSlot = self.materialSlots[i][j]
                        itemVnum, itemCount = materialInfo[0]
                        currentSlot.SetItemSlot(0, itemVnum, itemCount)
                        j = j + 1

                        # Center Align
                        item.SelectItem(itemVnum)
                        sizeX, sizeY = item.GetItemSize()
                        localX, localY = currentSlot.GetLocalPosition()

                        currentSlot.SetSize(self.SLOT_SIZEX,
                                            self.SLOT_SIZEY * sizeY)

                        adjustLocalY = 0
                        if sizeY < 3:
                            adjustLocalY = int(32 / sizeY)

                        currentSlot.SetPosition(localX, 0 + adjustLocalY)

                for k in xrange(5):
                    if k >= j:
                        self.materialSlots[i][k].ClearSlot(0)

                if self.RESULT_SLOT_COUNT <= i:
                    break

        self.cubeSlot.RefreshSlot()
Example #26
0
    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