当前位置: 首页>>代码示例>>Python>>正文


Python ItemDatabase.getOrDiscoverItemFromId方法代码示例

本文整理汇总了Python中kol.database.ItemDatabase.getOrDiscoverItemFromId方法的典型用法代码示例。如果您正苦于以下问题:Python ItemDatabase.getOrDiscoverItemFromId方法的具体用法?Python ItemDatabase.getOrDiscoverItemFromId怎么用?Python ItemDatabase.getOrDiscoverItemFromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kol.database.ItemDatabase的用法示例。


在下文中一共展示了ItemDatabase.getOrDiscoverItemFromId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseResponse

# 需要导入模块: from kol.database import ItemDatabase [as 别名]
# 或者: from kol.database.ItemDatabase import getOrDiscoverItemFromId [as 别名]
    def parseResponse(self):
        cantPulverizePattern = PatternManager.getOrCompilePattern('cantPulverizeItem')
        if cantPulverizePattern.search(self.responseText) != None:
            item = ItemDatabase.getOrDiscoverItemFromId(self.itemId, self.session)
            raise Error.Error("'%s' is not an item that can be pulverized." % item["name"], Error.WRONG_KIND_OF_ITEM)

        notEnoughItemsPattern = PatternManager.getOrCompilePattern('notEnoughItems')
        if notEnoughItemsPattern.search(self.responseText) != None:
            item = ItemDatabase.getOrDiscoverItemFromId(self.itemId, self.session)
            if self.quantity == 1:
                itemStr = item["name"]
            else:
                itemStr = item["plural"]
            raise Error.Error("You do not have %s (%s)." % (itemStr, self.quantity), Error.ITEM_NOT_FOUND)

        items = []

        singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
        for match in singleItemPattern.finditer(self.responseText):
            descId = int(match.group(1))
            item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
            item["quantity"] = 1
            items.append(item)

        multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
        for match in multiItemPattern.finditer(self.responseText):
            descId = int(match.group(1))
            quantity = int(match.group(2).replace(',', ''))
            item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
            item["quantity"] = quantity
            items.append(item)

        self.responseData["results"] = items
开发者ID:Alecat,项目名称:pykol,代码行数:35,代码来源:PulverizeRequest.py

示例2: parseResponse

# 需要导入模块: from kol.database import ItemDatabase [as 别名]
# 或者: from kol.database.ItemDatabase import getOrDiscoverItemFromId [as 别名]
    def parseResponse(self):
        """
        Searches backoffice.php for item name, quantity, price, limit, and ID.
        Returns the items with the usual keys in the item data base along with:

            quantity -- The number of the item in your mall store.
               price -- The price of the item in your mall store.
               limit -- The limit on the item in your mall store.
            cheapest -- The cheapest in mall. This includes limited items, use at own risk.
             orderId -- Item order in your store. 0 is the first listed and so on.
             
        RegExp match notes: Group 3,6,9, and 11 are garbage HTML data.
        """
        storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory')

        items = []
        for match in storeInventoryPattern.finditer(self.responseText):
            descId = match.group(1)
            orderId = match.group(2)
            name = match.group(4)
            quantity = match.group(5)
            itemID = int(match.group(7))
            item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session)
            price = match.group(8)
            limit = int(match.group(10))
            cheapest = int(match.group(12))
            
            item["orderId"] = orderId
            item["quantity"] = quantity
            item["price"] = price
            item["limit"] = limit
            item["cheapest"] = cheapest
            items.append(item)

        self.responseData["items"] = items
开发者ID:Cairnarvon,项目名称:pykol,代码行数:37,代码来源:StoreInventoryRequest.py

示例3: parseResponse

# 需要导入模块: from kol.database import ItemDatabase [as 别名]
# 或者: from kol.database.ItemDatabase import getOrDiscoverItemFromId [as 别名]
	def parseResponse(self):
		"""
		Searches managestore.php for item name, quantity, price, limit, and ID.
		Returns the items with the usual keys in the item data base along with:

			quantity -- The number of the item in your mall store.
			   price -- The price of the item in your mall store.
			   limit -- The limit on the item in your mall store.
		"""
		storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory')

		items = []
		for match in storeInventoryPattern.finditer(self.responseText):
			name = match.group(1)
			if match.group(2) == None:
				quantity = 1
			else:
				quantity = int(match.group(2))
			price = int(match.group(3).replace(',',''))
			if match.group(4) == '<font size=1>(unlimited)</font>&nbsp;&nbsp;':
				limit = 0
			else:
				limit = int(match.group(4))
			itemID = int(match.group(5))
			item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session)
			item["quantity"] = quantity
			item["price"] = price
			item["limit"] = limit
			items.append(item)

		self.responseData["items"] = items
开发者ID:Alecat,项目名称:pykol,代码行数:33,代码来源:StoreInventoryRequest.py

示例4: parseResponse

# 需要导入模块: from kol.database import ItemDatabase [as 别名]
# 或者: from kol.database.ItemDatabase import getOrDiscoverItemFromId [as 别名]
    def parseResponse(self):
        super(InventoryRequest, self).parseResponse()

        items = []
        for itemId, quantity in self.jsonData.iteritems():
            if self.ignoreItemDatabase:
                item = {}
                item["id"] = int(itemId)
                item["quantity"] = int(quantity)
                items.append(item)
            else:
                item = ItemDatabase.getOrDiscoverItemFromId(int(itemId), self.session)
                item["quantity"] = int(quantity)
            items.append(item)

        self.responseData["items"] = items
开发者ID:Alecat,项目名称:pykol,代码行数:18,代码来源:InventoryRequest.py

示例5: parseResponse

# 需要导入模块: from kol.database import ItemDatabase [as 别名]
# 或者: from kol.database.ItemDatabase import getOrDiscoverItemFromId [as 别名]
 def parseResponse(self):
     # Check for items first
     items = []
     itemsAcquiredPattern = PatternManager.getOrCompilePattern("acquireItemFromItemUse")
     for match in itemsAcquiredPattern.finditer(self.responseText):
         itemID = int(match.group(1))
         item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session)
         items.append(item)
     if len(items):
         self.responseData["items"] = items
     
     # Check for meat gained
     gainMeatPattern = PatternManager.getOrCompilePattern("gainMeat")
     for match in gainMeatPattern.finditer(self.responseText):
         self.responseData["meat"] = match.group(1)
     
     # Check if we don't have the item
     notEnoughPattern = PatternManager.getOrCompilePattern("notEnoughItems")
     notEnoughMatch = notEnoughPattern.search(self.responseText)    
     if notEnoughMatch:
         raise Error.Error("You don't appear to have that item")
     
     if not len(self.responseData):
         print self.responseText
开发者ID:metool,项目名称:pykol,代码行数:26,代码来源:UseItemRequest.py


注:本文中的kol.database.ItemDatabase.getOrDiscoverItemFromId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。