How to use the hearthstone.hslog.utils.parse_enum function in hearthstone

To help you get started, we’ve selected a few hearthstone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def meta_data(self, ts, meta, data, info):
		meta = parse_enum(enums.MetaDataType, meta)
		if meta == enums.MetaDataType.JOUST:
			data = parse_entity_id(data)
		count = int(info)
		self._metadata_node = packets.MetaData(ts, meta, data, count)
		self.current_block.packets.append(self._metadata_node)
		return self._metadata_node
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def _register_choices(self, ts, id, player, tasklist, type, min, max):
		id = int(id)
		type = parse_enum(enums.ChoiceType, type)
		min, max = int(min), int(max)
		self._choice_packet = packets.Choices(ts, player, id, tasklist, type, min, max)
		self.current_block.packets.append(self._choice_packet)
		return self._choice_packet
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def clean_option_errors(error, error_param):
	"""
	As of 8.0.0.18336, all option packets are accompanied by an error and an
	errorParam argument.
	This function turns both into their respective types.
	"""

	if error == "NONE":
		error = None
	else:
		error = parse_enum(PlayReq, error)

	if not error_param:
		error_param = None
	else:
		error_param = int(error_param)

	return error, error_param
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def _parse_option_packet(self, ts, data):
		if " errorParam=" in data:
			sre = tokens.OPTIONS_OPTION_ERROR_RE.match(data)
			optype, id, type, entity, error, error_param = sre.groups()
			if not sre:
				raise RegexParsingError(data)
			error, error_param = clean_option_errors(error, error_param)
		else:
			sre = tokens.OPTIONS_OPTION_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			optype, id, type, entity = sre.groups()
			error, error_param = None, None

		id = int(id)
		type = parse_enum(enums.OptionType, type)
		if entity:
			entity = self.parse_entity_or_player(entity)
		self._option_packet = packets.Option(ts, entity, id, type, optype, error, error_param)
		if not self._options_packet:
			raise ParsingError("Option without a parent option group: %r" % (data))

		self._options_packet.options.append(self._option_packet)
		self._suboption_packet = None

		return self._option_packet
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
def block_start(self, ts, entity, type, index, effectid, effectindex, target):
		id = self.parse_entity_or_player(entity)
		type = parse_enum(enums.BlockType, type)
		if index is not None:
			index = int(index)
		target = self.parse_entity_or_player(target)
		block = packets.Block(ts, id, type, index, effectid, effectindex, target)
		block.parent = self.current_block
		self.current_block.packets.append(block)
		self.current_block = block
		return block