def test_SoulOfTheForest(self):
     game = SavedGame("tests/replays/card_tests/SoulOfTheForest.rep")
     game.start()
     self.assertEqual(2, len(game.other_player.minions))
     self.assertEqual(2, game.other_player.minions[1].attack_power)
     self.assertEqual(2, game.other_player.minions[1].health)
     self.assertEqual("Treant", game.other_player.minions[1].card.name)
 def test_BlessingOfWisdom(self):
     game = SavedGame("tests/replays/card_tests/BlessingOfWisdom.rep")
     game.start()
     self.assertEqual(3, len(game.current_player.minions))
     # 7 cards have been drawn.
     # 3 for starting first, 3 for new turn and 1 for minion attack with Blessing of Wisdom (the second minion who had it got silenced)
     self.assertEqual(23, game.other_player.deck.left)
 def test_option_replay(self):
     game = SavedGame("tests/replays/stonetusk_power.rep")
     game.start()
     panther = game.other_player.minions[0]
     self.assertEqual(panther.card.name, "Panther")
     self.assertEqual(panther.health, 3)
     self.assertEqual(panther.attack_power, 4)
     self.assertEqual(panther.index, 0)
 def test_DruidOfTheClaw(self):
     game = SavedGame("tests/replays/card_tests/DruidOfTheClaw.rep")
     game.start()
     self.assertEqual(0, len(game.current_player.minions))
     self.assertEqual(1, len(game.other_player.minions))
     self.assertEqual(4, game.other_player.minions[0].attack_power)
     self.assertEqual(6, game.other_player.minions[0].max_health)
     self.assertEqual(2, game.other_player.minions[0].health)
     self.assertTrue(game.other_player.minions[0].taunt)
    def test_loading_game(self):
        game = SavedGame("tests/replays/example.rep")

        game.start()

        self.assertEqual(game.current_player.deck.character_class, CHARACTER_CLASS.DRUID)
        self.assertEqual(game.other_player.deck.character_class, CHARACTER_CLASS.MAGE)

        self.assertEqual(game.current_player.health, 29)
        self.assertTrue(game.current_player.dead)
    def test_ArcaneMissilesWithSpellPower(self):
        game = SavedGame("tests/replays/card_tests/ArcaneMissilesWithSpellDamage.rep")
        game.start()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual(1, game.other_player.minions[0].health)
        self.assertEqual(2, game.other_player.minions[0].calculate_max_health())
        self.assertEqual(27, game.other_player.hero.health)

        return game
    def test_NobleSacrifice(self):
        game = generate_game_for(NobleSacrifice, StonetuskBoar, SpellTestingAgent, PredictableBot)
        
        game.play_single_turn() # NobleSacrifice should be played
        self.assertEqual(1, len(game.players[0].secrets))
        self.assertEqual("Noble Sacrifice", game.players[0].secrets[0].name)

        game.play_single_turn() # Attack with Stonetusk should happen, and the secret should trigger. Both minions should die.
        self.assertEqual(0, len(game.players[0].secrets))
        self.assertEqual(0, len(game.players[0].minions))
        self.assertEqual(0, len(game.players[1].minions))
        self.assertEqual(30, game.players[0].health)
        
        # Test with 7 minions
        game = SavedGame("tests/replays/card_tests/NobleSacrifice.rep")
        game.start()
        self.assertEqual(7, len(game.players[0].minions))
        self.assertEqual(29, game.players[0].health)
        self.assertEqual(1, len(game.players[0].secrets))
        self.assertEqual("Noble Sacrifice", game.players[0].secrets[0].name)
    def test_Shadowform(self):
        game = generate_game_for(IronfurGrizzly, Shadowform, MinionPlayingAgent, PredictableBot)

        for turn in range(0, 9):
            game.play_single_turn()

        self.assertEqual("Lesser Heal", game.players[1].hero.power.__str__())

        # Shadowform should be played
        game.play_single_turn()
        self.assertEqual("Mind Spike", game.players[1].hero.power.__str__())

        # Nothing special
        game.play_single_turn()

        # Mind Spike should be used, and Shadowform should be played
        game.play_single_turn()
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual("Mind Shatter", game.players[1].hero.power.__str__())

        # Nothing special
        game.play_single_turn()
        self.assertEqual(5, len(game.players[0].minions))

        # Mind Shatter should be used, and Shadowform should be played
        # (but nothing will happen, we are already at Mind Shatter)
        game.play_single_turn()
        self.assertEqual("Mind Shatter", game.players[1].hero.power.__str__())
        self.assertEqual(4, len(game.players[0].minions))

        # Test using the hero power, then cast Shadowform and use the new power (this is possible)
        game = SavedGame("tests/replays/card_tests/Shadowform.rep")
        game.start()
        self.assertEqual(10, game.players[0].max_mana)
        self.assertEqual(3, game.players[0].mana)
        self.assertEqual(28, game.players[1].hero.health)