How to use the hearthstone.enums.PowerType 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 / tests / test_hslog.py View on Github external
assert game.players[0].account_hi == 1
	assert game.players[0].account_lo == 0
	assert game.players[0].is_ai
	assert not game.players[0].name

	assert game.players[1].id == 3
	assert game.players[1].player_id == 2
	assert game.players[1].account_hi == 3
	assert game.players[1].account_lo == 2
	assert not game.players[1].is_ai
	assert not game.players[1].name

	# Test packet structure
	assert len(packet_tree.packets) == 1
	packet = packet_tree.packets[0]
	assert packet.power_type == PowerType.CREATE_GAME
	assert packet.entity == game.id == 1

	# Player packet objects are not the same as players
	assert int(packet.players[0].entity) == game.players[0].id
	assert packet.players[0].player_id == game.players[0].player_id
	assert int(packet.players[1].entity) == game.players[1].id
	assert packet.players[1].player_id == game.players[1].player_id

	# All tags should be empty (we didn't pass any)
	assert not game.tags
	assert not game.players[0].tags
	assert not game.players[1].tags

	# Check some basic logic
	assert game.get_player(1) is game.players[0]
	assert game.get_player(2) is game.players[1]
github HearthSim / python-hslog / tests / test_main.py View on Github external
assert game.players[0].account_hi == 1
	assert game.players[0].account_lo == 0
	assert game.players[0].is_ai
	assert not game.players[0].name

	assert game.players[1].id == 3
	assert game.players[1].player_id == 2
	assert game.players[1].account_hi == 3
	assert game.players[1].account_lo == 2
	assert not game.players[1].is_ai
	assert not game.players[1].name

	# Test packet structure
	assert len(packet_tree.packets) == 1
	packet = packet_tree.packets[0]
	assert packet.power_type == PowerType.CREATE_GAME
	assert packet.entity == game.id == 1

	# Player packet objects are not the same as players
	assert int(packet.players[0].entity) == game.players[0].id
	assert packet.players[0].player_id == game.players[0].player_id
	assert int(packet.players[1].entity) == game.players[1].id
	assert packet.players[1].player_id == game.players[1].player_id

	# All tags should be empty (we didn't pass any)
	assert not game.tags
	assert not game.players[0].tags
	assert not game.players[1].tags

	# Check some basic logic
	assert game.get_player(1) is game.players[0]
	assert game.get_player(2) is game.players[1]
github HearthSim / python-hearthstone / tests / test_hslog.py View on Github external
def test_tag_change_unknown_entity_format():
	# Format changed in 15590
	parser = LogParser()
	parser.read(StringIO(INITIAL_GAME))
	parser.flush()

	entity_format = (
		"[name=UNKNOWN ENTITY [cardType=INVALID] id=24 zone=DECK zonePos=0 cardId= player=1]"
	)
	id = parse_entity_id(entity_format)
	assert id == 24

	data = "TAG_CHANGE Entity=%s tag=ZONE value=HAND" % (entity_format)
	packet = parser.handle_power(None, "TAG_CHANGE", data)
	assert packet.power_type == PowerType.TAG_CHANGE
	assert packet.entity == id
	assert packet.tag == GameTag.ZONE
	assert packet.value == Zone.HAND
github HearthSim / python-hearthstone / hearthstone / hslog / packets.py View on Github external
def __repr__(self):
		return "%s(entity=%r, type=%r, index=%r, target=%r)" % (
			self.__class__.__name__, self.entity, self.type, self.index, self.target
		)

	def end(self):
		self.ended = True

	def _export(self, game):
		for packet in self.packets:
			packet._export(game)


class MetaData(Packet):
	power_type = PowerType.META_DATA

	def __init__(self, ts, meta, data, count):
		self.ts = ts
		self.meta = meta
		self.data = data
		self.count = count
		self.info = []

	def __repr__(self):
		return "%s(meta=%r, data=%r)" % (self.__class__.__name__, self.meta, self.data)


class CreateGame(Packet):
	power_type = PowerType.CREATE_GAME

	class Player:
github HearthSim / python-hearthstone / hearthstone / hslog / packets.py View on Github external
self.entity = id
			self.player_id = player_id
			self.hi = hi
			self.lo = lo
			self.tags = []
			self.name = None

	def __init__(self, ts, entity):
		self.ts = ts
		self.entity = entity
		self.tags = []
		self.players = []


class HideEntity(Packet):
	power_type = PowerType.HIDE_ENTITY

	def __init__(self, ts, entity, zone):
		self.ts = ts
		self.entity = entity
		self.zone = zone


class FullEntity(Packet):
	power_type = PowerType.FULL_ENTITY

	def __init__(self, ts, entity, card_id):
		self.ts = ts
		self.entity = entity
		self.card_id = card_id
		self.tags = []
github HearthSim / python-hslog / hslog / packets.py View on Github external
def __repr__(self):
		return "%s(entity=%r, type=%r, index=%r, target=%r)" % (
			self.__class__.__name__, self.entity, self.type, self.index, self.target
		)

	def end(self):
		self.ended = True

	def _export(self, game):
		for packet in self.packets:
			packet._export(game)


class MetaData(Packet):
	power_type = PowerType.META_DATA

	def __init__(self, ts, meta, data, count):
		self.ts = ts
		self.meta = meta
		self.data = data
		self.count = count
		self.info = []

	def __repr__(self):
		return "%s(meta=%r, data=%r)" % (self.__class__.__name__, self.meta, self.data)


class CreateGame(Packet):
	power_type = PowerType.CREATE_GAME

	class Player:
github HearthSim / python-hearthstone / hearthstone / hslog / packets.py View on Github external
self.__class__.__name__, self.entity, self.card_id
		)


class ChangeEntity(Packet):
	power_type = PowerType.CHANGE_ENTITY

	def __init__(self, ts, entity, card_id):
		self.ts = ts
		self.entity = entity
		self.card_id = card_id
		self.tags = []


class TagChange(Packet):
	power_type = PowerType.TAG_CHANGE

	def __init__(self, ts, entity, tag, value):
		self.ts = ts
		self.entity = entity
		self.tag = tag
		self.value = value


class Choices(Packet):
	def __init__(self, ts, entity, id, tasklist, type, min, max):
		self.ts = ts
		self.entity = entity
		self.id = id
		self.tasklist = tasklist
		self.type = type
		self.min = min
github HearthSim / python-hslog / hslog / packets.py View on Github external
def end(self):
		self.ended = True


class CachedTagForDormantChange(Packet):
	power_type = PowerType.CACHED_TAG_FOR_DORMANT_CHANGE

	def __init__(self, ts, entity, tag, value):
		self.ts = ts
		self.entity = entity
		self.tag = tag
		self.value = value


class VOSpell(Packet):
	power_type = PowerType.VO_SPELL

	def __init__(self, ts, brguid, vospguid, blocking, delayms):
		self.ts = ts
		self.brguid = brguid
		self.vospguid = vospguid
		self.blocking = blocking
		self.delayms = delayms
github HearthSim / python-hearthstone / hearthstone / hslog / packets.py View on Github external
class MetaData(Packet):
	power_type = PowerType.META_DATA

	def __init__(self, ts, meta, data, count):
		self.ts = ts
		self.meta = meta
		self.data = data
		self.count = count
		self.info = []

	def __repr__(self):
		return "%s(meta=%r, data=%r)" % (self.__class__.__name__, self.meta, self.data)


class CreateGame(Packet):
	power_type = PowerType.CREATE_GAME

	class Player:
		def __init__(self, ts, id, player_id, hi, lo):
			self.ts = ts
			self.entity = id
			self.player_id = player_id
			self.hi = hi
			self.lo = lo
			self.tags = []
			self.name = None

	def __init__(self, ts, entity):
		self.ts = ts
		self.entity = entity
		self.tags = []
		self.players = []
github HearthSim / python-hearthstone / hearthstone / hslog / packets.py View on Github external
def export(self, cls=None):
		if cls is None:
			from .export import EntityTreeExporter as cls
		exporter = cls(self)
		return exporter.export()


class Packet:
	power_type = 0

	def __repr__(self):
		return "<%s>" % (self.__class__.__name__)


class Block(Packet):
	power_type = PowerType.BLOCK_START

	def __init__(self, ts, entity, type, index, effectid, effectindex, target):
		self.ts = ts
		self.entity = entity
		self.type = type
		self.index = index
		self.effectid = effectid
		self.effectindex = effectindex
		self.target = target
		self.ended = False
		self.packets = []

	def __iter__(self):
		for packet in self.packets:
			yield packet