Beispiel #1
0
    def parseResponse(self):
        weakSkillPattern = PatternManager.getOrCompilePattern('skillTooWeak')
        badSkillPattern = PatternManager.getOrCompilePattern(
            'skillNotTrainable')
        poorSkillPattern = PatternManager.getOrCompilePattern('skillTooPoor')
        haveSkillPattern = PatternManager.getOrCompilePattern(
            'skillHaveAlready')

        if weakSkillPattern.search(self.responseText):
            raise Error.Error(
                "You aren't a high enough level to train that skill.",
                Error.USER_IS_LOW_LEVEL)
        if badSkillPattern.search(self.responseText):
            raise Error.Error("You cannot train that skill at the Guild Hall.",
                              Error.SKILL_NOT_FOUND)
        if poorSkillPattern.search(self.responseText):
            raise Error.Error("You cannot afford to train that skill",
                              Error.NOT_ENOUGH_MEAT)
        if haveSkillPattern.search(self.responseText):
            raise Error.Error("You already know that skill.",
                              Error.ALREADY_COMPLETED)

        skillLearnedPattern = PatternManager.getOrCompilePattern(
            'skillLearned')
        match = skillLearnedPattern.search(self.responseText)
        skill = SkillDatabase.getSkillFromName(match.group(1))
        self.responseData["skill"] = skill
Beispiel #2
0
    def parseResponse(self):
        weakSkillPattern = PatternManager.getOrCompilePattern('skillTooWeak')
        badSkillPattern = PatternManager.getOrCompilePattern('skillNotTrainable')
        poorSkillPattern = PatternManager.getOrCompilePattern('skillTooPoor')
        haveSkillPattern = PatternManager.getOrCompilePattern('skillHaveAlready')

        if weakSkillPattern.search(self.responseText):
            raise Error.Error("You aren't a high enough level to train that skill.", Error.USER_IS_LOW_LEVEL)
        if badSkillPattern.search(self.responseText):
            raise Error.Error("You cannot train that skill at the Guild Hall.", Error.SKILL_NOT_FOUND)
        if poorSkillPattern.search(self.responseText):
            raise Error.Error("You cannot afford to train that skill", Error.NOT_ENOUGH_MEAT)
        if haveSkillPattern.search(self.responseText):
            raise Error.Error("You already know that skill.", Error.ALREADY_COMPLETED)

        skillLearnedPattern = PatternManager.getOrCompilePattern('skillLearned')
        match = skillLearnedPattern.search(self.responseText)
        skill = SkillDatabase.getSkillFromName(match.group(1))
        self.responseData["skill"] = skill
Beispiel #3
0
    def parseResponse(self):
        weakSkillPattern = PatternManager.getOrCompilePattern('skillTooWeak')
        badSkillPattern = PatternManager.getOrCompilePattern('skillNotTrainable')
        poorSkillPattern = PatternManager.getOrCompilePattern('skillTooPoor')
        haveSkillPattern = PatternManager.getOrCompilePattern('skillHaveAlready')

        if weakSkillPattern.search(self.responseText):
            raise InvalidActionError("You aren't a high enough level to train that skill")
        if badSkillPattern.search(self.responseText):
            raise SkillMissingError("You cannot train that skill at the Guild Hall")
        if poorSkillPattern.search(self.responseText):
            raise NotEnoughMeatError("You cannot afford to train that skill")
        if haveSkillPattern.search(self.responseText):
            raise RequestError("You already know that skill")

        skillLearnedPattern = PatternManager.getOrCompilePattern('skillLearned')
        match = skillLearnedPattern.search(self.responseText)
        if match:
            try:
                skill = SkillDatabase.getSkillFromName(match.group(1))
                self.responseData["skill"] = skill
            except SkillNotFoundError, inst:
                Report.error("bot", inst.message, inst)