Beispiel #1
0
    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.parseStatsGainedLost(
            self.responseText, checkMuscle=False, checkMoxie=False)
        self.responseData["level"] = ParseResponseUtils.parseLevelsGained(
            self.responseText)
Beispiel #2
0
 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)
Beispiel #3
0
    def parseResponse(self):
        notEnoughMeatPattern = PatternManager.getOrCompilePattern(
            'noMeatForStore')
        cannotGoPattern = PatternManager.getOrCompilePattern(
            'userShouldNotBeHere')
        notSoldPattern = PatternManager.getOrCompilePattern('notSoldHere')

        if cannotGoPattern.search(self.responseText):
            raise Error.Error("You cannot reach that cafe.",
                              Error.INVALID_LOCATION)
        if notSoldPattern.search(self.responseText):
            raise Error.Error("This cafe 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)

        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:
            response["hp"] = hpResponse

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

        self.responseData = response
Beispiel #4
0
    def parseResponse(self):
        # Check for errors
        tooFullPattern = PatternManager.getOrCompilePattern('tooFull')
        if tooFullPattern.search(self.responseText):
            raise Error.Error("You are too full to eat that.",
                              Error.USER_IS_FULL)
        notFoodPattern = PatternManager.getOrCompilePattern('notFood')
        if notFoodPattern.search(self.responseText):
            raise Error.Error("That item is not food.",
                              Error.WRONG_KIND_OF_ITEM)
        foodMissingPattern = PatternManager.getOrCompilePattern(
            'notEnoughItems')
        if foodMissingPattern.search(self.responseText):
            raise Error.Error("Item not in inventory.", Error.ITEM_NOT_FOUND)

        # Check the results
        results = {}
        results["adventures"] = ParseResponseUtils.parseAdventuresGained(
            self.responseText)

        substats = ParseResponseUtils.parseSubstatsGainedLost(
            self.responseText)
        if len(substats) > 0:
            results["substats"] = substats
        stats = ParseResponseUtils.parseStatsGainedLost(self.responseText)
        if len(stats) > 0:
            results["stats"] = stats
        level = ParseResponseUtils.parseLevelsGained(self.responseText)
        if level != 0:
            results["level"] = level
        hp = ParseResponseUtils.parseHPGainedLost(self.responseText)
        if hp != 0:
            results["hp"] = hp
        mp = ParseResponseUtils.parseMPGainedLost(self.responseText)
        if mp != 0:
            results["mp"] = mp
        effects = ParseResponseUtils.parseEffectsGained(self.responseText)
        if len(effects) > 0:
            results["effects"] = effects

        self.responseData = results
Beispiel #5
0
    def parseResponse(self):
        # Check for errors
        tooDrunkPattern = PatternManager.getOrCompilePattern('tooDrunk')
        if tooDrunkPattern.search(self.responseText):
            raise Error.Error("You are too drunk to drink more booze.", Error.USER_IS_DRUNK)
        notBoozePattern = PatternManager.getOrCompilePattern('notBooze')
        if notBoozePattern.search(self.responseText):
            raise Error.Error("That item is not booze.", Error.WRONG_KIND_OF_ITEM)
        boozeMissingPattern = PatternManager.getOrCompilePattern('notEnoughItems')
        if boozeMissingPattern.search(self.responseText):
            raise Error.Error("Item not in inventory.", Error.ITEM_NOT_FOUND)

        # Check the results
        results = {}
        results["drunkenness"] = ParseResponseUtils.parseDrunkGained(self.responseText)
        results["adventures"] = ParseResponseUtils.parseAdventuresGained(self.responseText)

        substats = ParseResponseUtils.parseSubstatsGainedLost(self.responseText)
        if len(substats) > 0:
            results["substats"] = substats
        stats = ParseResponseUtils.parseStatsGainedLost(self.responseText)
        if len(stats) > 0:
            results["stats"] = stats
        level = ParseResponseUtils.parseLevelsGained(self.responseText)
        if level != 0:
            results["level"] = level
        hp = ParseResponseUtils.parseHPGainedLost(self.responseText)
        if hp != 0:
            results["hp"] = hp
        mp = ParseResponseUtils.parseMPGainedLost(self.responseText)
        if mp != 0:
            results["mp"] = mp
        effects = ParseResponseUtils.parseEffectsGained(self.responseText)
        if len(effects) > 0:
            results["effects"] = effects

        self.responseData = results