How to use the hearthstone.entities.Card 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_entities.py View on Github external
def test_swift_messenger():
	card = Card(4, None)
	assert not card.initial_card_id
	assert card.is_original_entity

	card.reveal("GIL_528t", {})
	assert card.card_id == "GIL_528t"
	assert card.initial_card_id == "GIL_528t"
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_unidentified_contract():
	card = Card(4, None)
	assert not card.initial_card_id
	assert card.is_original_entity

	card.reveal("DAL_366", {})
	assert card.card_id == "DAL_366"
	assert card.initial_card_id == "DAL_366"

	card.change("DAL_366t3", {})
	assert card.card_id == "DAL_366t3"
	assert card.initial_card_id == "DAL_366"
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_cards():
	card1 = Card(4, "EX1_001")
	# The following should be instant.
	# If this test hangs, something's wrong in the caching mechanism...
	for i in range(1000):
		assert card1.base_tags.get(GameTag.HEALTH, 0) == 2
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_change_entity():
	card = Card(4, "EX1_001")
	assert card.card_id == "EX1_001"
	assert card.initial_card_id == "EX1_001"
	assert card.is_original_entity

	card.change("NEW1_030", {})
	assert card.card_id == "NEW1_030"
	assert card.initial_card_id == "EX1_001"
	assert not card.is_original_entity

	weapon = Card(4, None)
	assert not weapon.initial_card_id
	assert weapon.is_original_entity

	weapon.reveal("CS2_091", {GameTag.TRANSFORMED_FROM_CARD: 41420})
	assert weapon.card_id == "CS2_091"
	assert weapon.initial_card_id == "UNG_929"
	assert not weapon.is_original_entity
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_invalid_transformed_from_card():
	card = Card(4, None)
	card.reveal("EX1_001", {GameTag.TRANSFORMED_FROM_CARD: 0})
	assert card.initial_card_id == "EX1_001"
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_change_entity():
	card = Card(4, "EX1_001")
	assert card.card_id == "EX1_001"
	assert card.initial_card_id == "EX1_001"
	assert card.is_original_entity

	card.change("NEW1_030", {})
	assert card.card_id == "NEW1_030"
	assert card.initial_card_id == "EX1_001"
	assert not card.is_original_entity

	weapon = Card(4, None)
	assert not weapon.initial_card_id
	assert weapon.is_original_entity

	weapon.reveal("CS2_091", {GameTag.TRANSFORMED_FROM_CARD: 41420})
	assert weapon.card_id == "CS2_091"
	assert weapon.initial_card_id == "UNG_929"
github HearthSim / python-hearthstone / tests / test_entities.py View on Github external
def test_archthief_rafaam():
	card = Card(4, None)
	assert not card.initial_card_id
	assert card.is_original_entity

	card.reveal("CS2_091", {
		GameTag.CREATOR_DBID: 52119
	})
	assert card.card_id == "CS2_091"
	assert not card.initial_card_id
	assert not card.is_original_entity

	card.change("EX1_001", {})
	assert card.card_id == "EX1_001"
	assert not card.initial_card_id
	assert not card.is_original_entity
github HearthSim / python-hearthstone / hearthstone / hslog / export.py View on Github external
pass

	def handle_options(self, packet):
		pass

	def handle_option(self, packet):
		pass

	def handle_send_option(self, packet):
		pass


class EntityTreeExporter(BaseExporter):
	game_class = entities.Game
	player_class = entities.Player
	card_class = entities.Card

	class EntityNotFound(Exception):
		pass

	def find_entity(self, id, opcode):
		try:
			entity = self.game.find_entity_by_id(id)
		except RuntimeError as e:
			raise self.EntityNotFound("Error getting entity %r for %s" % (id, opcode))
		if not entity:
			raise self.EntityNotFound("Attempting %s on entity %r (not found)" % (opcode, id))
		return entity

	def handle_create_game(self, packet):
		self.game = self.game_class(packet.entity)
		self.game.create(packet.tags)
github HearthSim / python-hearthstone / hearthstone / entities.py View on Github external
def __init__(self, id, card_id):
		super(Card, self).__init__(id)
		self.is_original_entity = True
		self.initial_card_id = card_id
		self.card_id = card_id
		self.revealed = False
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

	def update_callback(self, caller):
		terminal_output("ENTITY UPDATED", self)
		# push data to an end-point
		pass


class LiveCard(Card, LiveEntity):
	"""
		Card is called on export from game
		LiveCard replaces Card and inserts update_callback
		The point is to become able to route update events towards an API end-point
	"""

	def __init__(self, entity_id, card_id):
		super(LiveCard, self).__init__(entity_id, card_id)

	"""
		if card_id doesn"t change, there"s no need to pass it as the argument.
		we can use self.card_id instead as it is set by Card class
	"""
	def reveal(self, card_id, tags):
		self.revealed = True
		self.card_id = card_id