def test_secrets(self):
        for secret_type in SecretCard.__subclasses__():
            random.seed(1857)
            secret = secret_type()
            game = generate_game_for(secret_type, StonetuskBoar, SpellTestingAgent, DoNothingBot)
            for turn in range(0, secret.mana * 2 - 2):
                game.play_single_turn()

            def assert_different():
                new_events = game.events.copy()
                new_events.update(game.other_player.hero.events)
                new_events.update(game.other_player.events)
                new_events.update(game.current_player.hero.events)
                new_events.update(game.current_player.events)
                self.assertNotEqual(events, new_events, secret.name)

            def assert_same():
                new_events = game.events.copy()
                new_events.update(game.current_player.hero.events)
                new_events.update(game.current_player.events)
                new_events.update(game.other_player.hero.events)
                new_events.update(game.other_player.events)
                self.assertEqual(events, new_events)

            game.current_player.bind("turn_ended", assert_different)
            game.other_player.bind("turn_ended", assert_same)

            # save the events as they are prior to the secret being played
            events = game.events.copy()
            events.update(game.other_player.hero.events)
            events.update(game.other_player.events)
            events.update(game.current_player.hero.events)
            events.update(game.current_player.events)

            # The secret is played, but the events aren't updated until the secret is activated
            game.play_single_turn()

            self.assertEqual(1, len(game.current_player.secrets))

            # Now the events should be changed
            game.play_single_turn()

            # Now the events should be reset
            game.play_single_turn()
Esempio n. 2
0
 def card_used(card):
     if type(card) in SecretCard.__subclasses__():
         player.unbind("card_used", card_used)
         player.unbind("turn_ended", turn_ended)
         player.mana_filters.remove(mana_filter)
Esempio n. 3
0
 def __init__(self):
     #To make sure that no matter what the cost of a secret, it will be 0
     self.amount = 100
     self.filter = lambda c: type(c) in SecretCard.__subclasses__()
     self.min = 0