def RefineItem(self, scrollSlotPos, targetSlotPos): scrollIndex = player.GetItemIndex(scrollSlotPos) targetIndex = player.GetItemIndex(targetSlotPos) if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos): return ########################################################### self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos) #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos) return ########################################################### ########################################################### #net.SendRequestRefineInfoPacket(targetSlotPos) #return ########################################################### result = player.CanRefine(scrollIndex, targetSlotPos) if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result: #snd.PlaySound("sound/ui/jaeryun_fail.wav") chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET) elif player.REFINE_NEED_MORE_GOOD_SCROLL == result: #snd.PlaySound("sound/ui/jaeryun_fail.wav") chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL) elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result: #snd.PlaySound("sound/ui/jaeryun_fail.wav") chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM) elif player.REFINE_NOT_NEXT_GRADE_ITEM == result: #snd.PlaySound("sound/ui/jaeryun_fail.wav") chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM) elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM) if player.REFINE_OK != result: return self.refineDialog.Open(scrollSlotPos, targetSlotPos)
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) itemVNum = player.GetItemIndex(attachedInvenType, attachedSlotPos) item.SelectItem(itemVNum) if app.ENABLE_OFFLINE_SHOP: itemCount = player.GetItemCount(attachedInvenType, attachedSlotPos) 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 if app.ENABLE_OFFLINE_SHOP: if self.type: priceInputBoard = uiCommon.NewMoneyInputDialog() else: priceInputBoard = uiCommon.MoneyInputDialog() else: 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.Open() itemPrice = GetPrivateShopItemPrice(itemVNum) if app.ENABLE_OFFLINE_SHOP: if itemPrice > 0: priceInputBoard.SetValue(itemPrice * itemCount) else: if itemPrice > 0: priceInputBoard.SetValue(itemPrice) self.priceInputBoard = priceInputBoard self.priceInputBoard.itemVNum = itemVNum if app.ENABLE_OFFLINE_SHOP: self.priceInputBoard.itemCount = itemCount self.priceInputBoard.sourceWindowType = attachedInvenType self.priceInputBoard.sourceSlotPos = attachedSlotPos self.priceInputBoard.targetSlotPos = selectedSlotPos
def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos): "대상 아이템에 사용할 수 있는가?" if srcSlotPos == dstSlotPos: return FALSE if 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
def RefineFail(self, reason, inven_type, inven_pos): if net.DS_SUB_HEADER_REFINE_FAIL == reason: self.__Initialize() self.Refresh() itemCount = player.GetItemCount(inven_type, inven_pos) if itemCount > 0: self.resultItemInfo[0] = (inven_type, inven_pos, itemCount) self.wndResultSlot.SetItemSlot(0, player.GetItemIndex(inven_type, inven_pos), itemCount) else: self.Refresh()
def __OnOverInItem(self, slotIndex): if slotIndex == 2: if self.slot_index1 != 999: itemVnum = player.GetItemIndex(self.slot_index1) self.tooltipItem.SetItemToolTip(itemVnum + 1) return if self.tooltipItem: if self.acceItemInfo.has_key(slotIndex): self.tooltipItem.SetInventoryItem(self.acceItemInfo[slotIndex])
def SellItem(self): if self.sellingSlotitemIndex == player.GetItemIndex( self.sellingSlotNumber): if self.sellingSlotitemCount == player.GetItemCount( self.sellingSlotNumber): ## 용혼석도 팔리게 하는 기능 추가하면서 인자 type 추가 net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY) snd.PlaySound("sound/ui/money.wav") self.OnCloseQuestionDialog()
def Open(self, metinItemPos, targetItemPos): self.metinItemPos = metinItemPos self.targetItemPos = targetItemPos metinIndex = player.GetItemIndex(metinItemPos) itemIndex = player.GetItemIndex(targetItemPos) self.oldToolTip.ClearToolTip() self.newToolTip.ClearToolTip() item.SelectItem(metinIndex) ## Metin Image try: self.metinImage.LoadImage(item.GetIconImageFileName()) except: dbg.TraceError( "AttachMetinDialog.Open.LoadImage - Failed to find item data") ## Old Item ToolTip metinSlot = [] for i in xrange(player.METIN_SOCKET_MAX_NUM): metinSlot.append(player.GetItemMetinSocket(targetItemPos, i)) self.oldToolTip.AddItemData(itemIndex, metinSlot) ## New Item ToolTip item.SelectItem(metinIndex) metinSubType = item.GetItemSubType() metinSlot = [] for i in xrange(player.METIN_SOCKET_MAX_NUM): metinSlot.append(player.GetItemMetinSocket(targetItemPos, i)) for i in xrange(player.METIN_SOCKET_MAX_NUM): slotData = metinSlot[i] if self.CanAttachMetin(slotData, metinSubType): metinSlot[i] = metinIndex break self.newToolTip.AddItemData(itemIndex, metinSlot) self.UpdateDialog() self.SetTop() self.Show()
def retrieveItems(self): OpenLog.DebugPrint("========= Retrieving item list ==========") for slot in range(SLOTS): item_id = player.GetItemIndex(slot) if item_id != 0: item.SelectItem(item_id) self.list.append( Item(item_id, slot, int(item.GetItemSize()[1]), item.GetItemName())) OpenLog.DebugPrint("========= Retrieving successful ==========")
def SellAttachedItem(self): if shop.IsPrivateShop(): mouseModule.mouseController.DeattachObject() return attachedSlotType = mouseModule.mouseController.GetAttachedType() attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedCount = mouseModule.mouseController.GetAttachedItemCount() if player.SLOT_TYPE_INVENTORY == attachedSlotType: itemIndex = player.GetItemIndex(attachedSlotPos) item.SelectItem(itemIndex) if item.IsAntiFlag(item.ANTIFLAG_SELL): popup = uiCommon.PopupDialog() popup.SetText(locale.SHOP_CANNOT_SELL_ITEM) popup.SetAcceptEvent(self.__OnClosePopupDialog) popup.Open() self.popup = popup elif player.IsValuableItem(attachedSlotPos): itemPrice = item.GetISellItemPrice() if item.Is1GoldItem(): itemPrice = attachedCount / itemPrice / 5 else: itemPrice = itemPrice * max(1, attachedCount) / 5 itemName = item.GetItemName() questionDialog = uiCommon.QuestionDialog() questionDialog.SetText( locale.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice)) questionDialog.SetAcceptEvent( lambda arg1=attachedSlotPos, arg2=attachedCount: self. OnSellItem(arg1, arg2)) questionDialog.SetCancelEvent( ui.__mem_func__(self.OnCloseQuestionDialog)) questionDialog.Open() self.questionDialog = questionDialog else: self.OnSellItem(attachedSlotPos, attachedCount) else: snd.PlaySound("sound/ui/loginfail.wav") mouseModule.mouseController.DeattachObject()
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 __UseItem(self, slotIndex): ItemVNum = player.GetItemIndex(slotIndex) item.SelectItem(ItemVNum) if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE): self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.SetText(locale.INVENTORY_REALLY_USE_ITEM) self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept)) self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel)) self.questionDialog.Open() self.questionDialog.slotIndex = slotIndex else: self.__SendUseItemPacket(slotIndex)
def Refresh(self): for i in xrange(shop.OFFLINE_SHOP_SLOT_COUNT): if (not self.itemStock.has_key(i)): self.itemSlot.ClearSlot(i) continue pos = self.itemStock[i] itemCount = player.GetItemCount(*pos) if (itemCount <= 1): itemCount = 0 self.itemSlot.SetItemSlot(i, player.GetItemIndex(*pos), itemCount) self.itemSlot.RefreshSlot()
def Refresh(self, iAct): self.sashSlot.ClearSlot(sash.WINDOW_MAX_MATERIALS) for i in xrange(sash.WINDOW_MAX_MATERIALS): self.sashSlot.ClearSlot(i) (isHere, iCell) = sash.GetAttachedItem(i) if isHere: self.sashSlot.SetItemSlot(i, player.GetItemIndex(iCell), 0) if i == int(sash.WINDOW_MAX_MATERIALS - 1): (itemVnum, MinAbs, MaxAbs) = sash.GetResultItem() if not itemVnum: break self.sashSlot.SetItemSlot(i + 1, itemVnum, 0) break
def GetItemByID(_id): """ Returns the index slot of first item found that matches any of the item id specified in the inventory. Args: id_list ([list]): List of item ids. Returns: [int]: Returns the index of the item or -1 if the item doesn't exist in the inventory. """ for i in range(0, MAX_INVENTORY_SIZE): if player.GetItemIndex(i) == _id: return i return -1
def __CanChangeItemAttrList(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return FALSE item.SelectItem(dstItemVNum) if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR): return FALSE for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: return TRUE return FALSE
def __CanCleanBrokenMetinStone(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return FALSE item.SelectItem(dstItemVNum) if item.ITEM_TYPE_WEAPON != item.GetItemType(): return FALSE for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE: return TRUE return FALSE
def Refresh(self, iAct): self.needMoney.SetText(localeInfo.SASH_REFINE_COST % (sash.GetPrice())) self.sashSlot.ClearSlot(sash.WINDOW_MAX_MATERIALS) for i in xrange(sash.WINDOW_MAX_MATERIALS): self.sashSlot.ClearSlot(i) (isHere, iCell) = sash.GetAttachedItem(i) if isHere: self.sashSlot.SetItemSlot(i, player.GetItemIndex(iCell), 0) if i == int(sash.WINDOW_MAX_MATERIALS - 1): (itemVnum, MinAbs, MaxAbs) = sash.GetResultItem() if not itemVnum: break self.sashSlot.SetItemSlot(i + 1, itemVnum, 0) break
def DropAllItemsSelected(self): ItemIndex = self.ListBoxItems.GetSelectedItem() if ItemIndex: pass else: chat.AppendChat(7, "[Inv-Manager] No selected Items!") return SelectedItem = ItemIndex.GetText().split(" ") selIdx = int(SelectedItem[1]) for i in range(0, OpenLib.MAX_INVENTORY_SIZE): idx = player.GetItemIndex(i) if idx != 0 and idx == selIdx: self.toDropSlots.append(i)
def UseAnyItemByID(id_list): """ Use the first item found that matches any of the id specified. Args: id_list ([list]): List of item ids. Returns: [int]: Returns 1 if the item was used or -1 otherwise. """ for i in range(0, MAX_INVENTORY_SIZE): if player.GetItemIndex(i) in id_list: net.SendItemUsePacket(i) return 1 return -1
def isRodAbleToLevelUp(self): idx = player.GetItemIndex(player.EQUIPMENT, item.EQUIPMENT_WEAPON) if (idx == 0): return False item.SelectItem(idx) currPoints = player.GetItemMetinSocket(player.EQUIPMENT, item.EQUIPMENT_WEAPON, 0) maxPoints = item.GetValue(2) if currPoints == maxPoints and item.GetItemType( ) == item.ITEM_TYPE_ROD: chat.AppendChat(3, "[Fishing-Bot] Rod is ready to be upgraded.") return True return False
def SellAllItemsSelected(self): if not shop.IsOpen(): chat.AppendChat(7, "[Inv-Manager] You need an open Shop for that!") return ItemIndex = self.ListBoxItems.GetSelectedItem() if ItemIndex: pass else: chat.AppendChat(7, "[Inv-Manager] No selected Items!") return SelectedItem = ItemIndex.GetText().split(" ") selIdx = int(SelectedItem[1]) for i in range(0, OpenLib.MAX_INVENTORY_SIZE): idx = player.GetItemIndex(i) if idx != 0 and idx == selIdx: self.toSellSlots.append(i)
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
def GetItemByType(_id): """ Return the slot index of the first item with the specified type in the inventory. Args: _id ([int]): The type of the item. Returns: [int]: Returns the slot index that matches the type or returns -1 if it is not found. """ for i in range(0, MAX_INVENTORY_SIZE): curr_id = player.GetItemIndex(i) if curr_id == 0: continue item.SelectItem(curr_id) if item.GetItemType() == _id: return i return -1
def isInventoryFull(): """ Check if invetory is full. The invtory is considered full when the number of empty slots is smaller then INV_FULL_MIN_EMPTY. Returns: [bool]: Returns True if is full or False otherwise. """ numItems = MAX_INVENTORY_SIZE for i in range(0, MAX_INVENTORY_SIZE): curr_id = player.GetItemIndex(i) if curr_id != 0: numItems -= 1 if numItems < INV_FULL_MIN_EMPTY: return True else: return False
def GoToShop(self): self.stopFishing() #if self.isRodDown: # self.isRodDown = False # net_packet.SendStopFishing(net_packet.UNSUCCESS_FISHING,0) #Check items to sell to_sell = [] has_worms = False has_fire = False for i in range(0, 90): idx = player.GetItemIndex(i) if idx != 0: if idx in self.catches: fishOptions = self.catches[idx] if 'buttonSell' in fishOptions.keys( ) and fishOptions['buttonSell'].isOn: to_sell.append(i) else: #Check if have worms and campfire if self.wormID == idx: has_worms = True if self.campFire == idx: has_fire = True to_buy = [] if not has_worms: for i in range(0, 5): to_buy.append(7) if not has_fire: to_buy.append(1) self.isMoving = True #GoShop and use campfire NPCInteraction.RequestBusinessNPCAway( to_buy, to_sell, NPCInteraction.GetFishermanShop(), callback=_PlaceFireCallBack) chat.AppendChat(3, "[Fishing-Bot] Selling slots: " + str(to_sell)) #NPCInteraction.RequestBusinessNPCAwayRestorePosition(to_buy,to_sell,NPCInteraction.FISHERMAN_SHOP,callback=_PositionRestoreCallback,pos=self.startPosition) self.SetState(self.STATE_GOING_TO_SHOP)
def SelectEmptySlot(self, slotIndex): try: if (constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1): return if (mouseModule.mouseController.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) 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.OFFLINE_SHOP_CANNOT_SELL_ITEM) return priceInputBoard = uiCommon.MoneyInputDialog() priceInputBoard.SetTitle(item.GetItemName() + "Fiyat") priceInputBoard.SetAcceptEvent( ui.__mem_func__(self.AcceptInputPrice)) priceInputBoard.SetCancelEvent( ui.__mem_func__(self.CancelInputPrice)) priceInputBoard.Open() self.priceInputBoard = priceInputBoard self.priceInputBoard.bDisplayPos = slotIndex self.priceInputBoard.bPos = attachedSlotPos except Exception, e: import dbg dbg.TraceError("Exception : SelectEmptySlot, %s" % (e))
def __CanAddItemAttr(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR): return False attrCount = 0 for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: attrCount += 1 if attrCount<4: return True return False
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 isItemTypeOnSlot(_type, invType=player.EQUIPMENT, slot=item.EQUIPMENT_WEAPON): """ Check if a specified item type exists in a specified slot. Args: _type ([int]): The item type. invType ([int], optional): The inventory type. Defaults to player.EQUIPMENT. slot ([type], optional): The slot number. Defaults to item.EQUIPMENT_WEAPON. Returns: [bool]: Returns True if item exist with the specified type or False otherwise. """ idx = player.GetItemIndex(invType, slot) if idx != 0: item.SelectItem(idx) if item.GetItemType() == _type: return True return False
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