Ejemplo n.º 1
0
	def parseResponse(self):
		response = {}
		respose["substats"] = ParseResponseUtils.parseSubstatsGained(self.responseText, checkMuscle=False, checkMysticality=False)
		respose["statPoints"] = ParseResponseUtils.ParseResponseUtils.parseStatPointsGained(self.responseText, checkMuscle=False, checkMysticality=False)
		response["level"] = ParseResponseUtils.parseLevelGained(self.responseText)
		
		self.responseData = response
Ejemplo n.º 2
0
	def parseResponse(self):
		response = {}
		effectResponse = ParseResponseUtils.parseEffectsGained(self.responseText)
		if len(effectResponse) > 0:
			response["effects"] = effectResponse
		hpResponse = ParseResponseUtils.parseHPGained(self.responseText)
		if hpResponse != 0:
			reponse["hp"] = hpResponse
		
		self.responseData = response
Ejemplo n.º 3
0
	def parseResponse(self):
		shouldNotBeHerePattern = PatternManager.getOrCompilePattern('userShouldNotBeHere')
		if shouldNotBeHerePattern.search(self.responseText)
			raise UserShouldNotBeHereError("Unable to adventure. You should not be here.")
		
		url = self.response.geturl()
		if url.find("/fight.php") >= 0:
			# See if the user tried to perform an invalid action.
			twiddlingThumbsPattern = PatternManager.getOrCompilePattern('twiddlingThumbs')
			if twiddlingThumbs.search(self.responseText)
				raise InvalidActionError("Could not perform action. Thumbs were twiddled.")
			
			# 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.session, self.responseText)
			self.responseData["meat"] = ParseResponseUtils.parseMeatReceived(self.responseText)
			self.responseData["substats"] = ParseResponseUtils.parseSubstatsGained(self.responseText)
			
		elif url.find("/choice.php") >= 0:
			self.responseData["adventureType"] = "choice"
			choiceIdentifierPattern = PatternManager.getOrCompilePattern('choiceIdentifier')
			choiceIdentifierMatch = choiceIdentifierPattern.search(self.responseText)
			if choiceIdentifierMatch:
				choiceNamePattern = PatternManager.getOrCompilePattern('choiceName')
				self.responseData["choiceId"] = choiceIdentifierMatch.group(1)
				self.responseData["choiceName"] = choiceNamePattern.search(self.responseText).group(1)
			else:
				self.responseData["items"] = ParseResponseUtils.parseItemsReceived(self.session, self.responseText)
				self.responseData["meat"] = ParseResponseUtils.parseMeatReceived(self.responseText)
				self.responseData["substats"] = ParseResponseUtils.parseSubstatsGained(self.responseText)
				
		elif url.find("/adventure.php") >= 0:
			self.responseData["adventureType"] = "noncombat"
			noncombatNamePattern = PatternManager.getOrCompilePattern('noncombatName')
			noncombatNameMatch = noncombatNamePattern.search(self.responseText)
			if noncombatNameMatch:
				self.responseData["noncombatName"] = noncombatNameMatch.group(1)
			self.responseData["items"] = ParseResponseUtils.parseItemsReceived(self.session, self.responseText)
			self.responseData["meat"] = ParseResponseUtils.parseMeatReceived(self.responseText)
			self.responseData["substats"] = ParseResponseUtils.parseSubstatsGained(self.responseText)
		else:
			raise RequestError("Adventure URL not recognized: %s" % url)
Ejemplo n.º 4
0
	def parseResponse(self):
		response = {}
		response["meat"] = ParseResponseUtils.parseMeatReceived(self.responseText)
		
		self.responseData = response
Ejemplo n.º 5
0
	def parseResponse(self):
		response = ParseResponseUtils.parseItemsReceived(self.session, self.responseText)
			
		self.responseData = response
Ejemplo n.º 6
0
    def parseResponse(self):
        response = ParseResponseUtils.parseEffectsGained(self.responseText)

        self.responseData = response