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


Python util.ParseResponseUtils类代码示例

本文整理汇总了Python中kol.util.ParseResponseUtils的典型用法代码示例。如果您正苦于以下问题:Python ParseResponseUtils类的具体用法?Python ParseResponseUtils怎么用?Python ParseResponseUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parseResponse

 def parseResponse(self):
     self.responseData["substats"] = ParseResponseUtils.parseSubstatsGainedLost(
         self.responseText, checkMuscle=False, checkMysticality=False
     )
     self.responseData["stats"] = ParseResponseUtils.parseStatsGainedLost(
         self.responseText, checkMuscle=False, checkMysticality=False
     )
     self.responseData["level"] = ParseResponseUtils.parseLevelsGained(self.responseText)
开发者ID:Cairnarvon,项目名称:pykol,代码行数:8,代码来源:TanULotsRequest.py

示例2: parseResponse

    def parseResponse(self):
        response = {}
        effectResponse = ParseResponseUtils.parseEffectsGained(self.responseText)
        if len(effectResponse) > 0:
            response["effects"] = effectResponse
        hpResponse = ParseResponseUtils.parseHPGainedLost(self.responseText)
        if hpResponse != 0:
            reponse["hp"] = hpResponse

        self.responseData = response
开发者ID:camperdave,项目名称:pykol,代码行数:10,代码来源:JukeboxRequest.py

示例3: parseResponse

    def parseResponse(self):
        if len(self.responseText) == 0:
            raise Error.Error("You cannot use the Mind Control Device yet.", Error.INVALID_LOCATION)

        noAdventuresPattern = PatternManager.getOrCompilePattern('noAdvInstitue')
        invalidTurnsPattern = PatternManager.getOrCompilePattern('invalidAdvInstitute')
        if noAdventuresPattern.search(self.responseText):
            raise Error.Error("You don't have enough adventures to study at the institute.", Error.NOT_ENOUGH_ADVENTURES)
        if invalidTurnsPattern.search(self.responseText):
            raise Error.Error("That is an invalid number of turns for studying." Error.REQUEST_GENERIC)

        self.responseData["substats"] = ParseResponseUtils.parseSubstatsGainedLost(self.responseText, checkMuscle=False, checkMoxie=False)
        self.responseData["stats"] = ParseResponseUtils.ParseResponseUtils.parseStatsGainedLost(self.responseText, checkMuscle=False, checkMoxie=False)
        self.responseData["level"] = ParseResponseUtils.parseLevelsGained(self.responseText)
开发者ID:nchusid,项目名称:pykol,代码行数:14,代码来源:CanadianStudiesRequest.py

示例4: parseResponse

	def parseResponse(self):
		if len(self.responseText) == 0:
			raise UserShouldNotBeHereError("You cannot use the Mind Control Device yet.")
		
		NoAdventuresPattern = PatternManager.getOrCompilePattern('noAdvInstitue')
		InvalidTurnsPattern = PatternManager.getOrCompilePattern('invalidAdvInstitute')
		
		if NoAdventuresPattern.search(self.responseText):
			raise NotEnoughAdventuresLeftError("You don't have enough adventures to study at the institute.")
		if InvalidTurnsPattern.search(self.responseText):
			raise RequestError("That is an invalid number of turns for studying")
		
		self.responseData["substats"] = ParseResponseUtils.parseSubstatsGainedLost(self.responseText, checkMuscle=False, checkMoxie=False)
		self.responseData["stats"] = ParseResponseUtils.ParseResponseUtils.parseStatsGainedLost(self.responseText, checkMuscle=False, checkMoxie=False)
		self.responseData["level"] = ParseResponseUtils.parseLevelsGained(self.responseText)
开发者ID:NardoLoopa,项目名称:pykol,代码行数:15,代码来源:CanadianStudiesRequest.py

示例5: parseResponse

    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
开发者ID:Alecat,项目名称:pykol,代码行数:29,代码来源:HermitRequest.py

示例6: parseResponse

	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(',', ''))
开发者ID:NardoLoopa,项目名称:pykol,代码行数:25,代码来源:MallItemPurchaseRequest.py

示例7: parseResponse

    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(',', ''))
开发者ID:Alecat,项目名称:pykol,代码行数:25,代码来源:MallItemPurchaseRequest.py

示例8: parseResponse

 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}
开发者ID:ijzer,项目名称:cwbot-ndy,代码行数:9,代码来源:SpecialShopRequest.py

示例9: parseResponse

	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.")
开发者ID:NardoLoopa,项目名称:pykol,代码行数:12,代码来源:MakePasteRequest.py

示例10: parseResponse

    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
开发者ID:camperdave,项目名称:pykol,代码行数:39,代码来源:BarrelRequest.py

示例11: parseResponse

    def parseResponse(self):
        # Check for errors.
        notEnoughMeatPattern = PatternManager.getOrCompilePattern('noMeatForStore')
        cannotGoPattern = PatternManager.getOrCompilePattern('userShouldNotBeHere')
        notSoldPattern = PatternManager.getOrCompilePattern('notSoldHere')

        if cannotGoPattern.search(self.responseText):
            raise UserShouldNotBeHereError("You cannot reach that cafe")
        if notSoldPattern.search(self.responseText):
            raise NotSoldHereError("This cafe doesn't carry that item.")
        if notEnoughMeatPattern.search(self.responseText):
            raise NotEnoughMeatError("You do not have enough meat to purchase the item(s).")

        response = {}

        advResponse = ParseResponseUtils.parseAdventuresGained(self.responseText)
        if advResponse > 0:
            response["adventures"] = advResponse

        drunkResponse = ParseResponseUtils.parseDrunkGained(self.responseText)
        if drunkResponse > 0:
            response["drunkeness"] = drunkResponse

        subResponse = ParseResponseUtils.parseSubstatsGainedLost(self.responseText)
        if len(subResponse) > 0:
            response["substats"] = subResponse

        statResponse = ParseResponseUtils.parseStatsGainedLost(self.responseText)
        if len(statResponse) > 0:
            response["statPoints"] = statResponse

        levelResponse = ParseResponseUtils.parseLevelsGained(self.responseText)
        if levelResponse > 0:
            response["level"] = levelResponse

        effectResponse = ParseResponseUtils.parseEffectsGained(self.responseText)
        if len(effectResponse) > 0:
            response["effects"] = effectResponse

        hpResponse = ParseResponseUtils.parseHPGainedLost(self.responseText)
        if hpResponse != 0:
            reponse["hp"] = hpResponse

        mpResponse = ParseResponseUtils.parseMPGainedLost(self.responseText)
        if mpResponse != 0:
            reponse["mp"] = mpResponse

        self.responseData = response
开发者ID:camperdave,项目名称:pykol,代码行数:48,代码来源:CafeRequest.py

示例12: parseResponse

    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(',', ''))
开发者ID:ijzer,项目名称:cwbot-ndy,代码行数:14,代码来源:GalaktikBuyRequest.py

示例13: parseResponse

 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
开发者ID:Alecat,项目名称:pykol,代码行数:18,代码来源:TravelingTraderRequest.py

示例14: parseResponse

    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.")
开发者ID:camperdave,项目名称:pykol,代码行数:18,代码来源:MeatpastingRequest.py

示例15: parseResponse

    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)
开发者ID:Cairnarvon,项目名称:pykol,代码行数:20,代码来源:MeatpastingRequest.py


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