本文整理汇总了Python中kol.util.ParseResponseUtils.parseItemsReceived方法的典型用法代码示例。如果您正苦于以下问题:Python ParseResponseUtils.parseItemsReceived方法的具体用法?Python ParseResponseUtils.parseItemsReceived怎么用?Python ParseResponseUtils.parseItemsReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kol.util.ParseResponseUtils
的用法示例。
在下文中一共展示了ParseResponseUtils.parseItemsReceived方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
cantAffordItemPattern = PatternManager.getOrCompilePattern('cantAffordItem')
if cantAffordItemPattern.search(self.responseText):
raise NotEnoughMeatError("You can not afford to buy this item.")
noItemAtThatPricePattern = PatternManager.getOrCompilePattern('mallNoItemAtThatPrice')
if noItemAtThatPricePattern.search(self.responseText):
raise NotSoldHereError("That item is not sold here at that price.")
ignoreListPattern = PatternManager.getOrCompilePattern('cantBuyItemIgnoreList')
if ignoreListPattern.search(self.responseText):
raise UserIsIgnoringError("The owner of that store has balleeted you.")
mallHitLimitPattern = PatternManager.getOrCompilePattern('mallHitLimit')
if mallHitLimitPattern.search(self.responseText):
raise MallLimitError("You have hit the limit for this item at this store.")
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise RequestError("Unknown error: %s" % self.responseText)
self.responseData["items"] = items
spentMeatPattern = PatternManager.getOrCompilePattern('meatSpent')
match = spentMeatPattern.search(self.responseText)
self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
示例2: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
cantAffordItemPattern = PatternManager.getOrCompilePattern('cantAffordItem')
if cantAffordItemPattern.search(self.responseText):
raise Error.Error("You can not afford to buy this item.", Error.NOT_ENOUGH_MEAT)
noItemAtThatPricePattern = PatternManager.getOrCompilePattern('mallNoItemAtThatPrice')
if noItemAtThatPricePattern.search(self.responseText):
raise Error.Error("That item is not sold here at that price.", Error.ITEM_NOT_FOUND)
ignoreListPattern = PatternManager.getOrCompilePattern('cantBuyItemIgnoreList')
if ignoreListPattern.search(self.responseText):
raise Error.Error("The owner of that store has balleeted you.", Error.USER_IS_IGNORING)
mallHitLimitPattern = PatternManager.getOrCompilePattern('mallHitLimit')
if mallHitLimitPattern.search(self.responseText):
raise Error.Error("You have hit the limit for this item at this store.", Error.LIMIT_REACHED)
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise Error.Error("Unknown error: %s" % self.responseText, Error.REQUEST_GENERIC)
self.responseData["items"] = items
spentMeatPattern = PatternManager.getOrCompilePattern('meatSpent')
match = spentMeatPattern.search(self.responseText)
self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
示例3: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
notEnoughCloversPattern = PatternManager.getOrCompilePattern('notEnoughClovers')
noTrinketsPattern = PatternManager.getOrCompilePattern('noTrinkets')
noHermitPermitPattern = PatternManager.getOrCompilePattern('noHermitPermits')
notHermitItemPattern = PatternManager.getOrCompilePattern('notHermitItem')
# Check for errors.
if notEnoughCloversPattern.search(self.responseText):
e = Error.Error("The Hermit doesn't have enough clovers for that.", Error.ITEM_NOT_FOUND)
e.itemId = 24
raise e
if noTrinketsPattern.search(self.responseText):
e = Error.Error("You don't have enough worthless items for that.", Error.ITEM_NOT_FOUND)
e.itemId = 43
raise e
if noHermitPermitPattern.search(self.responseText):
e = Error.Error("You don't have enough hermit permits for that.", Error.ITEM_NOT_FOUND)
e.itemId = 42
raise e
if notHermitItemPattern.search(self.responseText):
e = Error.Error("The Hermit doesn't have any of those.", Error.ITEM_NOT_FOUND)
e.itemId = self.requestData['whichitem']
raise e
response = {}
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
response["items"] = items
self.responseData = response
示例4: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
if self._buy:
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise Error.Error("Unknown error. No items received.", Error.REQUEST_FATAL)
self.responseData["items"] = items
found = self._itemsRegex.findall(self.responseText)
self.responseData["available"] = {name: row for name,row in found}
示例5: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
noMeatForPastePattern = PatternManager.getOrCompilePattern('noMeatForMeatpasting')
if noMeatForPastePattern.search(self.responseText):
raise NotEnoughMeatError("Unable to make the requested item. You don't have enough meat")
# Get the item(s) we received.
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
self.responseData["items"] = item
else:
raise RequestError("Unknown error. No items received.")
示例6: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
notBarrelPattern = PatternManager.getOrCompilePattern('usedBarrel')
noAdventuresPattern = PatternManager.getOrCompilePattern('noAdventures')
if notBarrelPattern.match(self.responseText):
raise InvalidActionError("Barrel already opened or doesn't exist. (#%s)" % self.requestData['smash'])
if noAdventuresPattern.match(self.responseText):
raise NotEnoughAdventuresLeftError("You don't have enough adventures to smash that")
url = self.response.geturl()
if url.find("/fight.php") >= 0:
# Get the monster's name.
self.responseData["adventureType"] = "combat"
monsterNamePattern = PatternManager.getOrCompilePattern('monsterName')
monsterNameMatch = monsterNamePattern.search(self.responseText)
self.responseData["monsterName"] = monsterNameMatch.group(1)
# Check to see if the fight was won or lost.
fightWonPattern = PatternManager.getOrCompilePattern('fightWon')
if fightWonPattern.search(self.responseText):
self.responseData["fightWon"] = True
else:
fightLostPattern = PatternManager.getOrCompilePattern('fightLost')
if fightLostPattern.search(self.responseText):
self.responseData["fightLost"] = True
# Get items, meat, and substats gained. We always need to check these since they can
# happen at any point during the fight.
self.responseData["items"] = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
self.responseData["meat"] = ParseResponseUtils.parseMeatGainedLost(self.responseText)
self.responseData["substats"] = ParseResponseUtils.parseSubstatsGainedLost(self.responseText)
item = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(item) > 0:
self.responseData["items"] = item
hp = ParseResponseUtils.parseHPGainedLost(self.responseText)
if hp != 0:
self.responseData["hp"] = hp
示例7: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
if self.notSold.search(self.responseText):
raise Error.Error("This store doesn't carry that item.", Error.ITEM_NOT_FOUND)
if self.notEnoughMeat.search(self.responseText):
raise Error.Error("You do not have enough meat to purchase the item(s).", Error.NOT_ENOUGH_MEAT)
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise Error.Error("Unknown error. No items received.", Error.REQUEST_FATAL)
self.responseData["items"] = items
meatSpentPattern = PatternManager.getOrCompilePattern('meatSpent')
match = meatSpentPattern.search(self.responseText)
self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
示例8: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Look for known errors. We override the NOT_ENOUGH_MEAT error here because it basically matches the error condition
# of not having enough currency to buy the particular product. It is not worth creating a one-off error for this
# particular situation, especially since the trader doesn't deal in meat.
p = PatternManager.getOrCompilePattern('traderNotTradingForThatItem')
if p.search(self.responseText):
raise Error.Error("The trader isn't trading for that item.", Error.ITEM_NOT_FOUND)
p = PatternManager.getOrCompilePattern('traderCantTradeForThatMany')
if p.search(self.responseText):
raise Error.Error("You are unable to trade for that many items.", Error.NOT_ENOUGH_MEAT)
p = PatternManager.getOrCompilePattern('traderNotEnoughWads')
if p.search(self.responseText):
raise Error.Error("You are unable to trade for that many items.", Error.NOT_ENOUGH_MEAT)
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise Error.Error("Unknown error. No items received.", Error.REQUEST_FATAL)
self.responseData["items"] = items
示例9: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
dontHaveMeatpastePattern = PatternManager.getOrCompilePattern('noMeatpaste')
itemsDontMeatpastePattern = PatternManager.getOrCompilePattern('itemsDontMeatpaste')
dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsMeatpaste')
if dontHaveMeatpastePattern.search(self.responseText):
raise NotEnoughItemsError("Unable to combine items. You don't have any meatpaste.")
elif itemsDontMeatpastePattern.search(self.responseText):
raise InvalidRecipeError("Unable to combine items. The submitted ingredients do not meatpaste together.")
elif dontHaveItemsPattern.search(self.responseText):
raise NotEnoughItemsError("Unable to combine items. You don't have all of the items you are trying to meatpaste.")
# Find the items attached to the message.
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
self.responseData["items"] = item
else:
raise RequestError("Unknown error.")
示例10: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
dontHaveMeatpastePattern = PatternManager.getOrCompilePattern('noMeatpaste')
itemsDontMeatpastePattern = PatternManager.getOrCompilePattern('itemsDontMeatpaste')
dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsMeatpaste')
if dontHaveMeatpastePattern.search(self.responseText):
e = Error.Error("Unable to combine items. You don't have any meatpaste.", Error.ITEM_NOT_FOUND)
e.itemId = 25
raise e
elif itemsDontMeatpastePattern.search(self.responseText):
raise Error.Error("Unable to combine items. The submitted ingredients do not meatpaste together.", Error.RECIPE_NOT_FOUND)
elif dontHaveItemsPattern.search(self.responseText):
raise Error.Error("Unable to combine items. You don't have all of the items you are trying to meatpaste.", Error.ITEM_NOT_FOUND)
# Find the items attached to the message.
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
self.responseData["items"] = items
else:
raise Error.Error("Unknown error meatpasting items: %s" % self.responseText, Error.REQUEST_FATAL)
示例11: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
notEnoughMeatPattern = PatternManager.getOrCompilePattern('noMeatForStore')
invalidStorePattern = PatternManager.getOrCompilePattern('invalidStore')
notSoldPattern = PatternManager.getOrCompilePattern('notSoldHere')
if len(self.responseText) == 0:
raise Error.Error("You cannot visit that store yet.", Error.INVALID_LOCATION)
if invalidStorePattern.search(self.responseText):
raise Error.Error("The store you tried to visit doesn't exist.", Error.INVALID_LOCATION)
if notSoldPattern.search(self.responseText):
raise Error.Error("This store doesn't carry that item.", Error.ITEM_NOT_FOUND)
if notEnoughMeatPattern.search(self.responseText):
raise Error.Error("You do not have enough meat to purchase the item(s).", Error.NOT_ENOUGH_MEAT)
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise Error.Error("Unknown error. No items received.", Error.REQUEST_FATAL)
self.responseData["items"] = items
meatSpentPattern = PatternManager.getOrCompilePattern('meatSpent')
match = meatSpentPattern.search(self.responseText)
self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
示例12: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# Check for errors.
notEnoughMeatPattern = PatternManager.getOrCompilePattern('noMeatForStore')
invalidStorePattern = PatternManager.getOrCompilePattern('invalidStore')
notSoldPattern = PatternManager.getOrCompilePattern('notSoldHere')
if len(self.responseText) == 0:
raise UserShouldNotBeHereError("You cannot visit that store yet.")
if invalidStorePattern.search(self.responseText):
raise NotAStoreError("The store you tried to visit doesn't exist.")
if notSoldPattern.search(self.responseText):
raise NotSoldHereError("This store doesn't carry that item.")
if notEnoughMeatPattern.search(self.responseText):
raise NotEnoughMeatError("You do not have enough meat to purchase the item(s).")
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) == 0:
raise RequestError("Unknown error. No items received.")
self.responseData["items"] = items
meatSpentPattern = PatternManager.getOrCompilePattern('meatSpent')
match = spentMeatPattern.search(self.responseText)
self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
示例13: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
# First parse for errors
notEnoughPattern = PatternManager.getOrCompilePattern("notEnoughToUse")
if notEnoughPattern.search(self.responseText):
raise NotEnoughItemsError("You don't have that many of that item")
notMultiPattern = PatternManager.getOrCompilePattern("notMultiUse")
if notMultiPattern.search(self.responseText):
raise InvalidActionError("You cannot multi-use that item")
# Find out what happened
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
self.responseData["items"] = items
meat = ParseResponseUtils.parseMeatGainedLost(self.responseText)
if meat != 0:
self.responseData["meat"] = meat
hp = ParseResponseUtils.parseHPGainedLost(self.responseText)
if hp != 0:
self.responseData["hp"] = hp
mp = ParseResponseUtils.parseMPGainedLost(self.responseText)
if mp != 0:
self.responseData["mp"] = mp
drunk = ParseResponseUtils.parseDrunkGained(self.responseText)
if drunk != 0:
self.responseData["drunk"] = drunk
adventures = ParseResponseUtils.parseAdventuresGained(self.responseText)
if adventures != 0:
self.responseData["adventures"] = adventures
effects = ParseResponseUtils.parseEffectsGained(self.responseText)
if len(effects) > 0:
self.responseData["effects"] = effects
示例14: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
notEnoughCloversPattern = PatternManager.getOrCompilePattern('notEnoughClovers')
noTrinketsPattern = PatternManager.getOrCompilePattern('noTrinkets')
noHermitPermitPattern = PatternManager.getOrCompilePattern('noHermitPermits')
notHermitItemPattern = PatternManager.getOrCompilePattern('notHermitItem')
# Check for errors.
if notEnoughCloversPattern.search(self.responseText):
raise RequestError("The Hermit doesn't have enough clovers for that")
if noTrinketsPattern.search(self.responseText):
raise NotEnoughItemsError("You don't have enough worthless items for that")
if noHermitPermitPattern.search(self.responseText):
raise NotEnoughHermitPermitsError("You don't have enough hermit permits for that")
if notHermitItemPattern.search(self.responseText):
raise NotSoldHereError("The Hermit doesn't have any of those")
response = {}
items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
if len(items) > 0:
response["items"] = items
self.responseData = response
示例15: parseResponse
# 需要导入模块: from kol.util import ParseResponseUtils [as 别名]
# 或者: from kol.util.ParseResponseUtils import parseItemsReceived [as 别名]
def parseResponse(self):
self.responseData["items"] = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)