How to use the hearthstone.enums.GameTag.CONTROLLER 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-hslog / tests / test_main.py View on Github external
GameTag.PLAYER_ID: 1,
		GameTag.TEAM_ID: 1,
		GameTag.ZONE: Zone.PLAY,
		GameTag.CONTROLLER: 1,
		GameTag.ENTITY_ID: 2,
		GameTag.CARDTYPE: CardType.PLAYER,
	}

	assert game.players[1].tags == {
		GameTag.PLAYSTATE: PlayState.PLAYING,
		GameTag.CURRENT_PLAYER: 1,
		GameTag.FIRST_PLAYER: 1,
		GameTag.PLAYER_ID: 2,
		GameTag.TEAM_ID: 2,
		GameTag.ZONE: Zone.PLAY,
		GameTag.CONTROLLER: 2,
		GameTag.ENTITY_ID: 3,
		GameTag.CARDTYPE: CardType.PLAYER,
	}
github HearthSim / python-hearthstone / tests / test_hslog.py View on Github external
GameTag.TURN: 1,
		GameTag.ZONE: Zone.PLAY,
		GameTag.ENTITY_ID: 1,
		GameTag.NEXT_STEP: Step.BEGIN_MULLIGAN,
		GameTag.CARDTYPE: CardType.GAME,
		GameTag.STATE: State.RUNNING,
	}
	assert game.initial_state == State.RUNNING
	assert game.initial_step == Step.INVALID

	assert game.players[0].tags == {
		GameTag.PLAYSTATE: PlayState.PLAYING,
		GameTag.PLAYER_ID: 1,
		GameTag.TEAM_ID: 1,
		GameTag.ZONE: Zone.PLAY,
		GameTag.CONTROLLER: 1,
		GameTag.ENTITY_ID: 2,
		GameTag.CARDTYPE: CardType.PLAYER,
	}

	assert game.players[1].tags == {
		GameTag.PLAYSTATE: PlayState.PLAYING,
		GameTag.CURRENT_PLAYER: 1,
		GameTag.FIRST_PLAYER: 1,
		GameTag.PLAYER_ID: 2,
		GameTag.TEAM_ID: 2,
		GameTag.ZONE: Zone.PLAY,
		GameTag.CONTROLLER: 2,
		GameTag.ENTITY_ID: 3,
		GameTag.CARDTYPE: CardType.PLAYER,
	}
github HearthSim / python-hearthstone / hearthstone / hslog / parser.py View on Github external
sre = tokens.GAME_ENTITY_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			id, = sre.groups()
			if int(id) != 1:
				raise ParsingError("GameEntity ID: Expected 1, got %r" % (id))
		elif opcode == "Player":
			self.flush()
			sre = tokens.PLAYER_ENTITY_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			self.register_player(ts, *sre.groups())
		elif opcode.startswith("tag="):
			tag, value = parse_initial_tag(data)
			self._entity_packet.tags.append((tag, value))
			if tag == GameTag.CONTROLLER:
				# We need to know entity controllers for player name registration
				self._packets.manager.register_controller(self._entity_packet.entity, value)
		elif opcode.startswith("Info["):
			if not self._metadata_node:
				logging.warning("Metadata Info outside of META_DATA: %r", data)
				return
			sre = tokens.METADATA_INFO_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			idx, entity = sre.groups()
			entity = self.parse_entity_or_player(entity)
			self._metadata_node.info.append(entity)
		else:
			raise NotImplementedError(data)
github HearthSim / python-hslog / hslog / live / entities.py View on Github external
def tag_change(self, tag, value):
		if tag == GameTag.CONTROLLER and not self._initial_controller:
			self._initial_controller = self.tags.get(GameTag.CONTROLLER, value)
		self.tags[tag] = value
		terminal_output("TAG UPDATED", self, tag, value)
		# push data to an end-point
		pass
github HearthSim / python-hearthstone / hearthstone / entities.py View on Github external
def _update_tags(self, tags):
		for tag, value in tags.items():
			if tag == GameTag.CONTROLLER and not self._initial_controller:
				self._initial_controller = self.tags.get(GameTag.CONTROLLER, value)
		self.tags.update(tags)
github HearthSim / python-hearthstone / hearthstone / hslog / export.py View on Github external
def handle_show_entity(self, packet):
		tags = dict(packet.tags)
		if GameTag.CONTROLLER in tags:
			self._controller_map[packet.entity] = tags[GameTag.CONTROLLER]

		if tags.get(GameTag.ZONE) != Zone.HAND:
			# Ignore cards already in play (such as enchantments, common in TB)
			return

		# The first SHOW_ENTITY packet will always be the friendly player's.
		self.friendly_player = self._controller_map[packet.entity]
github HearthSim / python-hslog / hslog / parser.py View on Github external
self.flush()
			self._creating_game = True
			sre = tokens.GAME_ENTITY_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			self.register_game(ts, *sre.groups())
		elif opcode == "Player":
			self.flush()
			sre = tokens.PLAYER_ENTITY_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			self.register_player(ts, *sre.groups())
		elif opcode.startswith("tag="):
			tag, value = parse_initial_tag(data)
			self._entity_packet.tags.append((tag, value))
			if tag == GameTag.CONTROLLER:
				# We need to know entity controllers for player name registration
				self._packets.manager.register_controller(self._entity_packet.entity, value)
		elif opcode.startswith("Info["):
			if not self._metadata_node:
				logging.warning("[%s] Metadata Info outside of META_DATA: %r", ts, data)
				return
			sre = tokens.METADATA_INFO_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
			idx, entity = sre.groups()
			entity = self.parse_entity_or_player(entity)
			self._metadata_node.info.append(entity)
		elif opcode == "Source":
			sre = tokens.SUB_SPELL_START_SOURCE_RE.match(data)
			if not sre:
				raise RegexParsingError(data)
github HearthSim / python-hslog / hslog / export.py View on Github external
def handle_tag_change(self, packet):
		if packet.tag == GameTag.CONTROLLER:
			self._controller_map[packet.entity] = packet.value
github HearthSim / python-hslog / hslog / live / entities.py View on Github external
def tag_change(self, tag, value):
		if tag == GameTag.CONTROLLER and not self._initial_controller:
			self._initial_controller = self.tags.get(GameTag.CONTROLLER, value)
		self.tags[tag] = value
		terminal_output("TAG UPDATED", self, tag, value)
		# push data to an end-point
		pass
github HearthSim / python-hearthstone / hearthstone / entities.py View on Github external
def initial_controller(self):
		return self.game.get_player(
			self._initial_controller or self.tags.get(GameTag.CONTROLLER, 0)
		)