diff --git a/hearthstone/entities.py b/hearthstone/entities.py index 3ab8731..1403415 100644 --- a/hearthstone/entities.py +++ b/hearthstone/entities.py @@ -118,7 +118,7 @@ def register_entity(self, entity: Entity) -> None: elif not self.setup_done: self.initial_entities.append(entity) - # Update player.starting_hero for Maestra of the Masquerade + # Infer player class and card from "Maestra of the Masquerade" revealing herself if ( entity.type == CardType.HERO and entity.tags.get(GameTag.CREATOR_DBID) == MAESTRA_DISGUISE_DBF_ID @@ -132,11 +132,22 @@ def register_entity(self, entity: Entity) -> None: # one. player.initial_hero_entity_id = entity.id - # At this point we know that Maestra must be in the starting of the player, - # because otherwise the reveal would not happen. Manually add it to the list - # of starting cards + # At this point we know that Maestra must be in the starting deck of the + # player, because otherwise the reveal would not happen. Manually add it to + # the list of starting cards player._known_starting_card_ids.add("SW_050") + # Infer Tourists when they reveal themselves + if ( + entity.tags.get(GameTag.ZONE) == Zone.REMOVEDFROMGAME and + entity.tags.get(GameTag.TOURIST) == 1 + ): + creator_id = entity.tags.get(GameTag.CREATOR) + creator = self.find_entity_by_id(creator_id) if creator_id else None + if creator and creator.card_id == "VAC_422e": # Tourist VFX Enchantment + player = entity.controller + player._known_starting_card_ids.add(entity.card_id) + def reset(self) -> None: for entity in self.entities: if entity is self: @@ -214,15 +225,14 @@ def known_starting_deck_list(self) -> List[str]: Blade) and well-known transforms (e.g. Spellstones, Unidentified Objects, Worgens) so that the initial card id is included rather than the final card id. """ - ret = list(self._known_starting_card_ids) - original_card_ids = [ get_original_card_id(entity.initial_card_id) for entity in self.initial_deck if entity.initial_card_id ] - ret = ret + [card_id for card_id in original_card_ids if card_id not in ret] - - return ret + return original_card_ids + [ + card_id for card_id in self._known_starting_card_ids + if card_id not in original_card_ids + ] @property def entities(self) -> Iterator[Entity]: diff --git a/tests/test_entities.py b/tests/test_entities.py index 5f573a4..54184ad 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -308,6 +308,46 @@ def test_known_starting_deck_list_with_souleaters_scythe(self, game, player): assert player.known_starting_deck_list == [WISP, SOULEATERS_SCYTHE] + def test_known_starting_deck_list_with_tourist(self, game, player): + HAMM = "VAC_340" + TOURIST_VFX_ENCHANTMENT = "VAC_422e" + + tourist = Card(4, None) + tourist.tags.update({ + GameTag.ZONE: Zone.DECK, + GameTag.CONTROLLER: player.player_id, + }) + game.register_entity(tourist) + + vfx = Card(5, None) + vfx.tags.update({ + GameTag.ZONE: Zone.SETASIDE, + GameTag.CONTROLLER: player.player_id, + }) + game.register_entity(vfx) + vfx.reveal(TOURIST_VFX_ENCHANTMENT, { + GameTag.CARDTYPE: CardType.ENCHANTMENT, + GameTag.ATTACHED: player.id, + GameTag.CREATOR: tourist.id, + }) + + # At some point we play an out-of-class card, and a fake tourist is shown + fake_tourist = Card(6, HAMM) + fake_tourist.tags.update({ + GameTag.CONTROLLER: player.player_id, + GameTag.CREATOR: vfx.id, + GameTag.ZONE: Zone.REMOVEDFROMGAME, + GameTag.TOURIST: 1, + GameTag.DRUID_TOURIST: 1, + }) + game.register_entity(fake_tourist) + + assert player.known_starting_deck_list == [HAMM] + + tourist.reveal(HAMM, {}) + + assert player.known_starting_deck_list == [HAMM] + class TestCard: def test_card(self):