def test_Wrath(self):
        game = generate_game_for(Wrath, StonetuskBoar, EnemyMinionSpellTestingAgent, OneCardPlayingAgent)
        game.play_single_turn()
        game.play_single_turn()

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

        game.play_single_turn()

        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual(5, len(game.current_player.hand))

        random.seed(1857)
        game = generate_game_for(Wrath, MogushanWarden, EnemyMinionSpellTestingAgent, OneCardPlayingAgent)
        game.players[0].agent.choose_option = lambda options, player: options[1]
        for turn in range(0, 8):
            game.play_single_turn()

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

        game.play_single_turn()

        self.assertEqual(1, len(game.other_player.minions))
        # Two wraths will have been played
        self.assertEqual(1, game.other_player.minions[0].health)
    def test_IceBarrier(self):
        game = generate_game_for(IceBarrier, StonetuskBoar, CardTestingAgent, PredictableAgent)
        for turn in range(0, 5):
            game.play_single_turn()

        self.assertEqual(1, len(game.current_player.secrets))
        self.assertEqual("Ice Barrier", game.current_player.secrets[0].name)

        game.play_single_turn()
        # only one minion because PredictableAgent will shoot its own minions if there isn't anything else to shoot.
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(7, game.other_player.hero.armor)

        # Attacked twice on the first turn, then fireballed before getting the armor up
        self.assertEqual(27, game.other_player.hero.health)

        # Make sure we can't have two identical secrets at the same time
        random.seed(1857)
        game = generate_game_for(IceBarrier, StonetuskBoar, CardTestingAgent, DoNothingAgent)
        for turn in range(0, 6):
            game.play_single_turn()

        self.assertEqual(1, len(game.other_player.secrets))
        self.assertEqual("Ice Barrier", game.other_player.secrets[0].name)

        game.play_single_turn()
        self.assertEqual(1, len(game.current_player.secrets))
        self.assertEqual("Ice Barrier", game.current_player.secrets[0].name)
    def test_Spellbender(self):
        game = generate_game_for([Spellbender, Wisp], Moonfire, CardTestingAgent, CardTestingAgent)

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

        # The moonfire should have been re-directed to the Spellbender, which should have taken one damage
        self.assertEqual(2, len(game.other_player.minions))
        self.assertEqual(2, game.other_player.minions[1].health)
        self.assertEqual(1, game.other_player.minions[1].calculate_attack())
        self.assertEqual("Spellbender", game.other_player.minions[1].card.name)

        # Now make sure it won't work when the hero is targeted
        random.seed(1857)
        game = generate_game_for(Spellbender, Moonfire, CardTestingAgent, CardTestingAgent)

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

        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual(1, len(game.other_player.secrets))
        self.assertEqual(23, game.other_player.hero.health)

        # Now make sure it doesn't activate when a non-targeted spell is used
        random.seed(1857)
        game = generate_game_for(Spellbender, ArcaneIntellect, CardTestingAgent, CardTestingAgent)

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

        # The arcane intellect should not have caused the Spellbender to activate
        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual(1, len(game.other_player.secrets))
Exemple #4
0
    def test_ExplosiveTrap(self):
        game = generate_game_for(ExplosiveTrap, StonetuskBoar, SpellTestingAgent, PlayAndAttackAgent)

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

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

        game.play_single_turn()

        self.assertEqual(0, len(game.other_player.secrets))
        self.assertEqual(0, len(game.current_player.minions))
        self.assertEqual(28, game.current_player.hero.health)
        self.assertEqual(29, game.other_player.hero.health)

        random.seed(1857)
        game = generate_game_for(ExplosiveTrap, Frostbolt, SpellTestingAgent, SpellTestingAgent)

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

        self.assertEqual(1, len(game.other_player.secrets))
        self.assertEqual(30, game.current_player.hero.health)
        self.assertEqual(27, game.other_player.hero.health)
    def test_Wrath(self):
        game = generate_game_for(Wrath, StonetuskBoar, EnemyMinionSpellTestingAgent, MinionPlayingAgent)
        game.play_single_turn()
        game.play_single_turn()

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

        game.play_single_turn()

        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual(5, len(game.current_player.hand))

        random.seed(1857)
        game = generate_game_for(Wrath, MogushanWarden, EnemyMinionSpellTestingAgent, MinionPlayingAgent)
        game.players[0].agent.choose_option = Mock(side_effect=lambda one, three: three)
        for turn in range(0, 8):
            game.play_single_turn()

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

        game.play_single_turn()

        self.assertEqual(1, len(game.other_player.minions))
        #Two wraths will have been played
        self.assertEqual(1, game.other_player.minions[0].defense)
    def test_Snowchugger(self):
        game = generate_game_for(Snowchugger, StonetuskBoar, PredictableAgent, DoNothingAgent)

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

        self.assertEqual(27, game.other_player.hero.health)
        self.assertFalse(game.other_player.hero.frozen_this_turn)
        self.assertFalse(game.other_player.hero.frozen)
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(2, game.current_player.minions[0].calculate_attack())
        self.assertEqual(3, game.current_player.minions[0].health)
        self.assertEqual("Snowchugger", game.current_player.minions[0].card.name)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(25, game.other_player.hero.health)

        # Always false after the end of a turn
        self.assertFalse(game.other_player.hero.frozen_this_turn)
        self.assertTrue(game.other_player.hero.frozen)

        # Now make sure that attacking the Snowchugger directly will freeze a character
        random.seed(1857)
        game = generate_game_for(Snowchugger, IronbarkProtector, OneCardPlayingAgent, PredictableAgent)
        for turn in range(0, 4):
            game.play_single_turn()

        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual(2, game.other_player.minions[0].health)
        # The player should be frozen because of weapon attack
        self.assertEqual(29, game.current_player.hero.health)
        self.assertTrue(game.current_player.hero.frozen)

        game.play_single_turn()
        game.play_single_turn()

        # The player should still be frozen from last turn, and thus shouldn't have attacked
        self.assertEqual(29, game.current_player.hero.health)

        # If Snowchugger gets 0 attack, and is being attacked so will the minion NOT be frozen since no damage was dealt
        game = generate_game_for(Snowchugger, StonetuskBoar, PredictableAgent, PredictableAgent)

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

        self.assertEqual(1, len(game.players[1].minions))
        self.assertEqual("Snowchugger", game.players[1].minions[0].card.name)
        # Cheat
        game.players[1].minions[0].base_attack = 0
        self.assertEqual(0, game.players[1].minions[0].calculate_attack())
        self.assertEqual(3, game.players[1].minions[0].health)

        # Stonetusk should have attacked the Snowchugger, and will NOT be frozen since they didn't take damage
        game.play_single_turn()
        self.assertEqual(1, game.players[1].minions[0].health)
        self.assertFalse(game.players[0].minions[0].frozen_this_turn)
        self.assertFalse(game.players[0].minions[0].frozen)
    def test_DarkWispers(self):
        game = generate_game_for(DarkWispers, SaltyDog, CardTestingAgent, OneCardPlayingAgent)
        game.players[0].agent.choose_option = lambda options, player: options[1]
        for turn in range(0, 10):
            game.play_single_turn()

        # 1 Salty Dog on the field
        self.assertEqual(0, len(game.players[0].minions))
        self.assertEqual(1, len(game.players[1].minions))
        self.assertEqual(7, game.players[1].minions[0].calculate_attack())
        self.assertEqual(4, game.players[1].minions[0].health)
        self.assertFalse(game.players[1].minions[0].taunt)

        # Chooses to buff enemy Salty Dog
        game.play_single_turn()

        self.assertEqual(0, len(game.players[0].minions))
        self.assertEqual(1, len(game.players[1].minions))
        self.assertEqual(12, game.players[1].minions[0].calculate_attack())
        self.assertEqual(9, game.players[1].minions[0].health)
        self.assertTrue(game.players[1].minions[0].taunt)

        random.seed(1857)
        game = generate_game_for(DarkWispers, SaltyDog, CardTestingAgent, OneCardPlayingAgent)
        for turn in range(0, 10):
            game.play_single_turn()

        # 1 Salty Dog on the field
        self.assertEqual(0, len(game.players[0].minions))
        self.assertEqual(1, len(game.players[1].minions))

        # Summons 5 Wisps
        game.play_single_turn()

        self.assertEqual(5, len(game.players[0].minions))
        self.assertEqual(1, len(game.players[1].minions))
        self.assertEqual(1, game.players[0].minions[0].calculate_attack())
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual("Wisp", game.players[0].minions[0].card.name)
        self.assertEqual(1, game.players[0].minions[1].calculate_attack())
        self.assertEqual(1, game.players[0].minions[1].health)
        self.assertEqual("Wisp", game.players[0].minions[1].card.name)
        self.assertEqual(1, game.players[0].minions[2].calculate_attack())
        self.assertEqual(1, game.players[0].minions[2].health)
        self.assertEqual("Wisp", game.players[0].minions[2].card.name)
        self.assertEqual(1, game.players[0].minions[3].calculate_attack())
        self.assertEqual(1, game.players[0].minions[3].health)
        self.assertEqual("Wisp", game.players[0].minions[3].card.name)
        self.assertEqual(1, game.players[0].minions[4].calculate_attack())
        self.assertEqual(1, game.players[0].minions[4].health)
        self.assertEqual("Wisp", game.players[0].minions[4].card.name)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(7, len(game.players[0].minions))
    def test_KeeperOfTheGrove(self):
        # Test Moonfire option

        game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, OneCardPlayingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(3, len(game.current_player.minions))

        game.play_single_turn()

        self.assertEqual(2, len(game.other_player.minions))

        # Test Dispel option

        random.seed(1857)

        game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, OneCardPlayingAgent)

        game.players[0].agent.choose_option = lambda options, player: options[1]

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertTrue(game.current_player.minions[0].charge())

        game.play_single_turn()

        self.assertFalse(game.other_player.minions[0].charge())

        # Test when there are no targets for the spell
        random.seed(1857)
        game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual("Keeper of the Grove", game.current_player.minions[0].card.name)
    def test_Nourish(self):

        # Test gaining two mana
        game = generate_game_for(Nourish, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(7, game.current_player.max_mana)
        self.assertEqual(7, len(game.current_player.hand))

        # Ensure that the case where we would be over 10 mana is handled correctly

        game.play_single_turn()
        game.play_single_turn()
        # Nourish is played.  it brings the player to 10

        self.assertEqual(10, game.current_player.max_mana)
        self.assertEqual(5, game.current_player.mana)

        game.play_single_turn()
        game.play_single_turn()

        # Nourish is played.  It doesn't affect the max_mana, but it does fill in two crystals.
        # Tested on patch 2.1.0.7785
        self.assertEqual(10, game.current_player.max_mana)
        self.assertEqual(7, game.current_player.mana)

        # Test drawing three cards
        random.seed(1857)
        game = generate_game_for(Nourish, StonetuskBoar, CardTestingAgent, DoNothingAgent)
        game.players[0].agent.choose_option = lambda options, player: options[1]

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(10, len(game.current_player.hand))
        self.assertEqual(5, game.current_player.max_mana)
    def test_AncientOfLore(self):
        game = generate_game_for(AncientOfLore, Starfire, MinionPlayingAgent, EnemySpellTestingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        self.assertEqual(game.other_player.health, 25)

        game.play_single_turn()

        self.assertEqual(30, game.current_player.health)
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(5, game.current_player.minions[0].health)
        self.assertEqual(5, game.current_player.minions[0].attack_power)
        self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)

        random.seed(1857)

        game = generate_game_for(AncientOfLore, StonetuskBoar, MinionPlayingAgent, DoNothingBot)

        game.players[0].agent.choose_option = Mock(side_effect=lambda heal, draw: draw)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        self.assertEqual(10, len(game.current_player.hand))
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(5, game.current_player.minions[0].health)
        self.assertEqual(5, game.current_player.minions[0].attack_power)
        self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
    def test_AncientOfLore(self):
        game = generate_game_for(AncientOfLore, Starfire, OneCardPlayingAgent, EnemySpellTestingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        self.assertEqual(game.other_player.hero.health, 25)

        game.play_single_turn()

        self.assertEqual(30, game.current_player.hero.health)
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(5, game.current_player.minions[0].health)
        self.assertEqual(5, game.current_player.minions[0].calculate_attack())
        self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)

        random.seed(1857)

        game = generate_game_for(AncientOfLore, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)

        game.players[0].agent.choose_option = lambda options, player: options[1]

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        self.assertEqual(10, len(game.current_player.hand))
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(5, game.current_player.minions[0].health)
        self.assertEqual(5, game.current_player.minions[0].calculate_attack())
        self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
Exemple #12
0
    def test_TundraRhino(self):
        game = generate_game_for([StonetuskBoar, OasisSnapjaw, TundraRhino], StonetuskBoar,
                                 PlayAndAttackAgent, DoNothingAgent)
        for turn in range(0, 6):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(27, game.players[1].hero.health)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual(26, game.players[1].hero.health)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(3, len(game.players[0].minions))
        self.assertEqual(21, game.players[1].hero.health)
        self.assertTrue(game.players[0].minions[0].charge)
        self.assertTrue(game.players[0].minions[1].charge)
        self.assertTrue(game.players[0].minions[2].charge)

        game.players[0].minions[2].silence()
        self.assertTrue(game.players[0].minions[2].charge)
Exemple #13
0
    def test_UnboundElemental(self):
        game = generate_game_for([UnboundElemental, DustDevil, DustDevil], StonetuskBoar, MinionPlayingAgent,
                                 DoNothingBot)

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

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Unbound Elemental", game.players[0].minions[0].card.name)
        self.assertEqual(2, game.players[0].minions[0].calculate_attack())
        self.assertEqual(4, game.players[0].minions[0].calculate_max_health())

        # One Dust Devil should be played, giving the Unbound Elemental +1/+1
        game.play_single_turn()
        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual(3, game.players[0].minions[-1].calculate_attack())
        self.assertEqual(5, game.players[0].minions[-1].calculate_max_health())
        # Test the silence
        game.players[0].minions[-1].silence()
        self.assertEqual(2, game.players[0].minions[-1].calculate_attack())
        self.assertEqual(4, game.players[0].minions[-1].calculate_max_health())

        # Another Dust Devil, nothing should happen because of silence
        game.play_single_turn()
        game.play_single_turn()
        self.assertEqual(3, len(game.players[0].minions))
        self.assertEqual(2, game.players[0].minions[-1].calculate_attack())
        self.assertEqual(4, game.players[0].minions[-1].calculate_max_health())
    def test_GrommashHellscream(self):
        game = generate_game_for(GrommashHellscream, ExplosiveTrap, PlayAndAttackAgent, CardTestingAgent)

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

        # Hellscream should be played, attacking (charge) and getting 2 damage by trap that will trigger enrage,
        # dealing 10 damage as result
        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(10, game.players[0].minions[0].calculate_attack())
        self.assertEqual(7, game.players[0].minions[0].health)
        self.assertEqual(20, game.players[1].hero.health)

        game.players[0].minions[0].heal(2, None)
        self.assertEqual(4, game.players[0].minions[0].calculate_attack())
        game.players[0].minions[0].damage(2, None)
        self.assertEqual(10, game.players[0].minions[0].calculate_attack())

        game.players[0].minions[0].silence()
        self.assertEqual(4, game.players[0].minions[0].calculate_attack())
        game.players[0].minions[0].heal(2, None)
        self.assertEqual(4, game.players[0].minions[0].calculate_attack())
        game.players[0].minions[0].damage(2, None)
        self.assertEqual(4, game.players[0].minions[0].calculate_attack())
Exemple #15
0
    def test_AncestralSpirit(self):
        game = generate_game_for([ArgentCommander, AncestralSpirit], StonetuskBoar, MinionPlayingAgent, DoNothingBot)

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

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Argent Commander", game.players[0].minions[0].card.name)
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertTrue(game.players[0].minions[0].divine_shield)

        game.play_single_turn()
        # Ancestral Spirit should be played on the Argent Commander
        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        game.players[0].minions[0].health = 1
        game.players[0].minions[0].divine_shield = False
        # Let the minion die in order to test Ancestral Spirit
        commander = game.players[0].minions[0]
        commander.die(None)
        commander.activate_delayed()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Argent Commander", game.players[0].minions[0].card.name)
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertTrue(game.players[0].minions[0].divine_shield)
    def test_WeeSpellstopper(self):
        game = generate_game_for(WeeSpellstopper, ShadowBolt, OneCardPlayingAgent, OneCardPlayingAgent)
        for turn in range(0, 8):
            game.play_single_turn()

        # First Spellstopper gets Bolted but lives with 1 hp
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(1, game.players[0].minions[0].health)

        # Once there are 2 Spellstoppers, they are both spell immune
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual(5, game.players[0].minions[0].health)
        self.assertEqual(1, game.players[0].minions[1].health)

        game.play_single_turn()
        game.players[0].minions[0].die(None)
        game.players[0].minions[1].die(None)
        game.check_delayed()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(1, game.players[0].minions[0].health)

        # Last Spellstopper is not immune and dies to Shadow Bolt
        game.play_single_turn()

        self.assertEqual(0, len(game.players[0].minions))
    def test_ConeOfCold(self):
        game = generate_game_for(ConeOfCold, [StonetuskBoar, BloodfenRaptor, BloodfenRaptor], CardTestingAgent,
                                 OneCardPlayingAgent)

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

        self.assertEqual(3, len(game.current_player.minions))

        game.play_single_turn()

        self.assertEqual(3, len(game.other_player.minions))
        self.assertTrue(game.other_player.minions[0].frozen)
        self.assertEqual(1, game.other_player.minions[0].health)
        self.assertTrue(game.other_player.minions[1].frozen)
        self.assertEqual(1, game.other_player.minions[1].health)
        self.assertFalse(game.other_player.minions[2].frozen)
        self.assertEqual(1, game.other_player.minions[2].health)
        self.assertEqual(30, game.other_player.hero.health)

        # Now check to ensure that it will work when targeting the other end of the minion list
        game.current_player.agent.choose_target = lambda targets: targets[len(targets) - 1]
        game.play_single_turn()
        game.play_single_turn()

        # Neither of the minions which survive Cone of Cold will be frozen, since they weren't touched this round
        self.assertEqual(2, len(game.other_player.minions))
        self.assertFalse(game.other_player.minions[0].frozen)
        self.assertFalse(game.other_player.minions[1].frozen)
    def test_SorcerersApprentice(self):
        game = generate_game_for([SorcerersApprentice, ArcaneMissiles, SorcerersApprentice, Frostbolt, Frostbolt,
                                  Frostbolt], StonetuskBoar, CardTestingAgent, DoNothingAgent)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(3, game.current_player.minions[0].calculate_attack())
        self.assertEqual(2, game.current_player.minions[0].health)
        self.assertEqual("Sorcerer's Apprentice", game.current_player.minions[0].card.name)

        # Arcane missiles should also have been played, since it is now free
        self.assertEqual(27, game.other_player.hero.health)

        # Make sure the other frostbolts have been properly reduced
        self.assertEqual(1, game.current_player.hand[1].mana_cost())
        self.assertEqual(1, game.current_player.hand[2].mana_cost())

        game.play_single_turn()
        game.play_single_turn()

        # Both Sorcerer's Apprentices are killed by friendly Frostbolts.
        self.assertEqual(0, len(game.current_player.minions))

        # Make sure that the cards in hand are no longer reduced
        self.assertEqual(2, game.current_player.hand[0].mana_cost())
    def test_BouncingBlades(self):
        game = generate_game_for([GoldshireFootman, EchoingOoze, BouncingBlade], [GoldshireFootman, EchoingOoze],
                                 CardTestingAgent, CardTestingAgent)

        for turn in range(4):
            game.play_single_turn()

        self.assertEqual(3, len(game.players[0].minions))
        self.assertEqual(3, len(game.players[1].minions))
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertEqual(2, game.players[0].minions[1].health)
        self.assertEqual(2, game.players[0].minions[2].health)
        self.assertEqual(2, game.players[1].minions[0].health)
        self.assertEqual(2, game.players[1].minions[1].health)
        self.assertEqual(2, game.players[1].minions[2].health)

        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual(3, len(game.players[1].minions))

        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertEqual(1, game.players[0].minions[1].health)
        self.assertEqual(2, game.players[1].minions[0].health)
        self.assertEqual(2, game.players[1].minions[1].health)
        self.assertEqual(1, game.players[1].minions[2].health)
Exemple #20
0
    def test_Flare(self):

        game = generate_game_for(Vaporize, [WorgenInfiltrator, WorgenInfiltrator, ArcaneShot, Flare],
                                 SpellTestingAgent, SpellTestingAgent)

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

        # Vaporize is in place and two Infiltrators are down
        self.assertEqual(1, len(game.current_player.secrets))
        self.assertEqual(2, len(game.other_player.minions))
        self.assertTrue(game.other_player.minions[0].stealth)
        self.assertTrue(game.other_player.minions[1].stealth)
        self.assertEqual(4, len(game.other_player.hand))

        old_play = game.other_player.agent.do_turn

        def _play_and_attack(player):
            old_play(player)
            player.minions[2].attack()

        # Flare, The Coin, two Worgens and Arcane shot are played
        # Arcane shot kills one of the active Worgens, because Flare has removed its stealth
        game.other_player.agent.do_turn = _play_and_attack
        game.play_single_turn()
        self.assertEqual(0, len(game.other_player.secrets))
        self.assertEqual(3, len(game.current_player.minions))
        self.assertFalse(game.current_player.minions[2].stealth)
        self.assertEqual(1, len(game.current_player.hand))
    def test_FlameImp(self):
        game = generate_game_for(FlameImp, StonetuskBoar, MinionPlayingAgent, DoNothingBot)

        game.play_single_turn()
        # play Flame Imp, 3 damage to own hero
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(27, game.players[0].hero.health)
Exemple #22
0
    def test_FreezingTrap_many_cards(self):
        class FreezingTrapAgent(DoNothingAgent):
            def do_turn(self, player):
                if player.mana == 6:
                    game.play_card(player.hand[0])
                if player.mana == 7:
                    player.minions[0].attack()
        game = generate_game_for(FreezingTrap, BoulderfistOgre, SpellTestingAgent, FreezingTrapAgent)

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

        self.assertEqual(1, len(game.current_player.minions))
        death_mock = mock.Mock()
        game.players[1].minions[0].bind_once("died", death_mock)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(10, len(game.current_player.hand))
        self.assertEqual(0, len(game.current_player.minions))
        for card in game.current_player.hand:
            if card.name != "The Coin":
                self.assertEqual(6, card.mana_cost(game.current_player))
        self.assertEqual(30, game.other_player.hero.health)
        death_mock.assert_called_once_with(None)
 def test_PitLord(self):
     game = generate_game_for(PitLord, StonetuskBoar, MinionPlayingAgent, DoNothingBot)
     for turn in range(0, 7):
         game.play_single_turn()
         # play Pit Lord, 5 damage to own hero
     self.assertEqual(1, len(game.players[0].minions))
     self.assertEqual(25, game.players[0].hero.health)
    def test_LightsJustice(self):
        game = generate_game_for(LightsJustice, StonetuskBoar, PredictableAgent, DoNothingAgent)

        # Light's Justice should be played
        game.play_single_turn()
        self.assertEqual(1, game.players[0].hero.weapon.base_attack)
        self.assertEqual(4, game.players[0].hero.weapon.durability)
    def test_RepentanceSelf(self):
        game = generate_game_for([Repentance, BluegillWarrior], TwilightDrake, CardTestingAgent, DoNothingAgent)
        for turn in range(0, 3):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].secrets))
        self.assertEqual(1, len(game.players[0].minions))
Exemple #26
0
    def test_FrostShock(self):
        game = generate_game_for(FrostShock, StonetuskBoar, SpellTestingAgent, DoNothingBot)

        # Frost Shock should be played
        game.play_single_turn()
        self.assertEqual(29, game.players[1].hero.health)
        self.assertTrue(game.players[1].hero.frozen)
    def test_SwordOfJustice(self):
        game = generate_game_for([SwordOfJustice, MagmaRager, MagmaRager, MagmaRager, MagmaRager, MagmaRager],
                                 StonetuskBoar, OneCardPlayingAgent, OneCardPlayingAgent)

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

        # Sword of Justice should be played, and hero will attack once
        game.play_single_turn()
        self.assertEqual(1, game.players[0].hero.weapon.base_attack)
        self.assertEqual(5, game.players[0].hero.weapon.durability)

        # Four minions should have been played, buffing each one
        for turn in range(0, 9):
            game.play_single_turn()
        self.assertEqual(1, game.players[0].hero.weapon.durability)
        self.assertEqual(4, len(game.players[0].minions))
        for i in range(0, 4):
            self.assertEqual(2, game.players[0].minions[i].calculate_max_health())
            self.assertEqual(2, game.players[0].minions[i].health)
            self.assertEqual(6, game.players[0].minions[i].calculate_attack())

        # A fifth minion should be played, buffed by the last durability of the weapon which should be destroyed
        game.play_single_turn()
        self.assertEqual(None, game.players[0].hero.weapon)
        self.assertEqual(5, len(game.players[0].minions))
        self.assertEqual(2, game.players[0].minions[0].calculate_max_health())
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertEqual(6, game.players[0].minions[0].calculate_attack())

        game.players[0].minions[0].silence()
        self.assertEqual(1, game.players[0].minions[0].calculate_max_health())
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual(5, game.players[0].minions[0].calculate_attack())
    def test_Brawl(self):
        game = generate_game_for(Brawl, StonetuskBoar, CardTestingAgent, DoNothingAgent)

        game.players[0].mana = 100

        shield = Shieldbearer()
        shield.use(game.players[0], game)
        shield.use(game.players[0], game)
        golem = HarvestGolem()
        golem.use(game.players[0], game)
        shield.use(game.players[1], game)
        shield.use(game.players[1], game)
        shield.use(game.players[1], game)

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

        self.assertEqual(3, len(game.players[0].minions))
        self.assertEqual(3, len(game.players[1].minions))

        # Brawl should be played, leaving one minion behind and Damaged Golem should have spawned for first player
        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Damaged Golem", game.players[0].minions[0].card.name)
        self.assertEqual(1, len(game.players[1].minions))
    def test_HeroicStrike(self):
        game = generate_game_for(HeroicStrike, StonetuskBoar, PlayAndAttackAgent, DoNothingAgent)

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

        self.assertEqual(26, game.players[1].hero.health)
Exemple #30
0
    def test_BestialWrath(self):

        def verify_bwrath():
            self.assertEqual(3, game.other_player.minions[0].calculate_attack())
            self.assertTrue(game.other_player.minions[0].immune)

        def verify_silence():
            self.assertFalse(game.other_player.minions[0].immune)
            self.assertEqual(1, game.other_player.minions[0].calculate_attack())

        game = generate_game_for(StonetuskBoar, [BestialWrath, BestialWrath, BestialWrath, Silence, BoulderfistOgre],
                                 OneCardPlayingAgent, EnemyMinionSpellTestingAgent)
        game.play_single_turn()
        game.other_player.bind_once("turn_ended", verify_bwrath)
        game.play_single_turn()
        self.assertEqual(1, len(game.other_player.minions))
        self.assertFalse(game.other_player.minions[0].immune)
        self.assertEqual(1, game.other_player.minions[0].calculate_attack())

        game.play_single_turn()
        game.other_player.bind_once("turn_ended", verify_silence)
        game.play_single_turn()
        self.assertEqual(2, len(game.other_player.minions))
        self.assertFalse(game.other_player.minions[0].immune)
        self.assertEqual(1, game.other_player.minions[0].calculate_attack())
        self.assertEqual(2, len(game.players[1].hand))
Exemple #31
0
    def test_Redemption_full_board(self):
        game = generate_game_for(
            Assassinate,
            [Redemption, Wisp, Wisp, Wisp, Wisp, Wisp, HauntedCreeper],
            OneCardPlayingAgent, CardTestingAgent)
        for turn in range(0, 8):
            game.play_single_turn()

        self.assertEqual(6, len(game.current_player.minions))

        game.play_single_turn()
        # This has been tested locally on patch 2.1.0.7628
        self.assertEqual(7, len(game.other_player.minions))
        self.assertEqual("Spectral Spider",
                         game.other_player.minions[0].card.name)
        self.assertEqual("Spectral Spider",
                         game.other_player.minions[1].card.name)
        self.assertEqual("Wisp", game.other_player.minions[2].card.name)
        self.assertEqual("Wisp", game.other_player.minions[3].card.name)
        self.assertEqual("Wisp", game.other_player.minions[4].card.name)
        self.assertEqual("Wisp", game.other_player.minions[5].card.name)
        self.assertEqual("Wisp", game.other_player.minions[6].card.name)
Exemple #32
0
    def testGahzrilla_temp_buff(self):
        env = self

        class TestAgent(CardTestingAgent):
            def do_turn(self, player):
                super().do_turn(player)
                if turn == 14:
                    # Gahz'rilla's double comes after the buff from abusive, so total attack is
                    # (6 + 2) * 2 = 16
                    env.assertEqual(
                        16, game.current_player.minions[0].calculate_attack())

        game = generate_game_for([Gahzrilla, AbusiveSergeant, Hellfire],
                                 StonetuskBoar, TestAgent, DoNothingAgent)

        for turn in range(15):
            game.play_single_turn()

        # After the buff wears off, the double no longer includes it, so the total attack is
        # 6 * 2 = 12
        # Tested by @jleclanche for patch 2.1.0.7785
        self.assertEqual(12, game.current_player.minions[0].calculate_attack())
Exemple #33
0
    def test_Acidmaw(self):
        game = generate_game_for(
            [Acidmaw, ArcaneExplosion, InjuredBlademaster], OasisSnapjaw,
            CardTestingAgent, OneCardPlayingAgent)

        for turn in range(14):
            game.play_single_turn()

        # Three snapjaws
        self.assertEqual(4, len(game.current_player.minions))

        # One Acidmaw
        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual("Acidmaw", game.other_player.minions[0].card.name)

        game.play_single_turn()
        # The snapjaws are dead from the arcane explosion
        self.assertEqual(0, len(game.other_player.minions))

        # The blademaster dies as well.
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual("Acidmaw", game.current_player.minions[0].card.name)
Exemple #34
0
    def test_MortalCoil(self):
        game = generate_game_for(BloodfenRaptor, MortalCoil, DoNothingAgent, OneCardPlayingAgent)

        raptor = BloodfenRaptor()
        raptor.summon(game.players[0], game, 0)
        # player 0 plays raptor
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertEqual(5, len(game.players[1].hand))

        game.play_single_turn()
        game.play_single_turn()
        # mortal coils the 2hp raptor
        self.assertEqual(5, len(game.players[1].hand))
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(1, game.players[0].minions[0].health)

        game.play_single_turn()
        game.play_single_turn()
        # mortal coils the 1hp raptor and draws
        self.assertEqual(0, len(game.players[0].minions))
        self.assertEqual(6, len(game.players[1].hand))
Exemple #35
0
    def test_TreeOfLife(self):
        game = generate_game_for([SpiderTank, Hellfire, TreeOfLife],
                                 [SpiderTank, Deathwing], OneCardPlayingAgent,
                                 OneCardPlayingAgent)
        for turn in range(0, 16):
            game.play_single_turn()

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

        game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(1, len(game.players[1].minions))
        self.assertEqual(4, game.players[0].minions[0].health)
        self.assertEqual(4, game.players[1].minions[0].health)
        self.assertEqual(30, game.current_player.hero.health)
        self.assertEqual(30, game.other_player.hero.health)
Exemple #36
0
    def test_GladiatorsLongbow(self):
        game = generate_game_for(GladiatorsLongbow, WaterElemental, WeaponTestingAgent,
                                 OneCardPlayingAgent)
        for turn in range(0, 13):
            game.play_single_turn()

        self.assertEqual(3, len(game.other_player.minions))
        self.assertEqual(1, game.other_player.minions[0].health)
        self.assertEqual(30, game.current_player.hero.health)
        self.assertFalse(game.current_player.hero.frozen)
        self.assertFalse(game.current_player.hero.immune)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(4, len(game.other_player.minions))
        self.assertEqual(1, game.other_player.minions[0].health)
        self.assertEqual(1, game.other_player.minions[1].health)
        self.assertEqual(30, game.current_player.hero.health)
        self.assertFalse(game.current_player.hero.frozen)
        self.assertFalse(game.current_player.hero.immune)
        self.assertEqual(0, len(game.current_player.events))
Exemple #37
0
    def test_Mindgames(self):
        game = generate_game_for(Mindgames, MogushanWarden, SpellTestingAgent,
                                 DoNothingBot)

        # Mindgames should be played, Mogu'shan Warden will be found and put into the battlefield
        for turn in range(0, 7):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Mogu'shan Warden",
                         game.players[0].minions[0].card.name)

        # Cheat
        for index in range(0, 30):
            game.players[1].deck.used[index] = True

        game.play_single_turn()
        game.play_single_turn()
        # Mindgames should be played, opponent have no cards left in deck so Shadow of Nothing should be summoned
        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual("Shadow of Nothing",
                         game.players[0].minions[0].card.name)
Exemple #38
0
    def test_Snipe(self):
        game = generate_game_for([MagmaRager, OasisSnapjaw, FeralSpirit],
                                 Snipe, CardTestingAgent, CardTestingAgent)

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

        self.assertEqual(0, len(game.current_player.minions))

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(3, game.current_player.minions[0].health)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(3, len(game.current_player.minions))
        self.assertEqual(3, game.current_player.minions[0].health)
        self.assertEqual(3, game.current_player.minions[1].health)
        self.assertEqual(3, game.current_player.minions[2].health)
Exemple #39
0
    def test_ForceOfNature(self):
        game = generate_game_for(
            [ForceOfNature, Innervate, FacelessManipulator], StonetuskBoar,
            create_friendly_copying_agent(10), DoNothingBot)
        for turn in range(0, 18):
            game.play_single_turn()

        def check_minions():
            self.assertEqual(4, len(game.current_player.minions))

            for minion in game.current_player.minions:
                self.assertEqual(2, minion.calculate_attack())
                self.assertEqual(2, minion.health)
                self.assertEqual(2, minion.calculate_max_health())
                self.assertTrue(minion.charge)
                self.assertEqual("Treant", minion.card.name)

        game.other_player.bind_once("turn_ended", check_minions)

        game.play_single_turn()

        self.assertEqual(0, len(game.other_player.minions))
    def test_FeralSpirit(self):
        game = generate_game_for(FeralSpirit, StonetuskBoar, CardTestingAgent,
                                 DoNothingAgent)

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

        self.assertEqual(2, len(game.players[0].minions))

        self.assertEqual(2, game.players[0].minions[0].calculate_attack())
        self.assertEqual(3, game.players[0].minions[0].health)
        self.assertTrue(game.players[0].minions[0].taunt)
        self.assertEqual("Spirit Wolf", game.players[0].minions[0].card.name)
        self.assertEqual(2, game.players[0].minions[0].card.mana)

        self.assertEqual(2, game.players[0].minions[1].calculate_attack())
        self.assertEqual(3, game.players[0].minions[1].health)
        self.assertTrue(game.players[0].minions[1].taunt)
        self.assertEqual("Spirit Wolf", game.players[0].minions[1].card.name)
        self.assertEqual(2, game.players[0].minions[1].card.mana)

        self.assertEqual(2, game.players[0].upcoming_overload)
Exemple #41
0
    def test_Avenge(self):
        game = generate_game_for([Avenge, StonetuskBoar, StonetuskBoar],
                                 Frostbolt, CardTestingAgent, CardTestingAgent)

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

        self.assertEqual(2, len(game.current_player.minions))
        self.assertEqual(1, game.current_player.minions[0].calculate_attack())
        self.assertEqual(1,
                         game.current_player.minions[0].calculate_max_health())
        self.assertEqual(1, game.current_player.minions[1].calculate_attack())
        self.assertEqual(1,
                         game.current_player.minions[1].calculate_max_health())

        game.play_single_turn()

        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual(4, game.other_player.minions[0].calculate_attack())
        self.assertEqual(3,
                         game.other_player.minions[0].calculate_max_health())
        self.assertEqual(0, len(game.other_player.secrets))
Exemple #42
0
    def test_Lightbomb(self):
        game = generate_game_for([ChillwindYeti, Lightbomb], [ArgentSquire, FaerieDragon, SpiderTank, Deathwing],
                                 OneCardPlayingAgent, OneCardPlayingAgent)
        for turn in range(0, 10):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(3, len(game.players[1].minions))
        self.assertEqual(5, game.players[0].minions[0].health)
        self.assertEqual(4, game.players[1].minions[0].health)
        self.assertEqual(2, game.players[1].minions[1].health)
        self.assertEqual(1, game.players[1].minions[2].health)
        self.assertTrue(game.players[1].minions[2].divine_shield)

        game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(2, len(game.players[1].minions))
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual(1, game.players[1].minions[0].health)
        self.assertEqual(1, game.players[1].minions[1].health)
        self.assertFalse(game.players[1].minions[1].divine_shield)
    def test_Hex(self):
        game = generate_game_for(ChillwindYeti, Hex, OneCardPlayingAgent,
                                 CardTestingAgent)

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

        self.assertEqual(1, len(game.players[0].minions))
        self.assertFalse(game.players[0].minions[0].taunt)
        self.assertEqual(4, game.players[0].minions[0].calculate_attack())
        self.assertEqual(5, game.players[0].minions[0].health)
        self.assertEqual("Chillwind Yeti",
                         game.players[0].minions[0].card.name)

        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertTrue(game.players[0].minions[0].taunt)
        self.assertEqual(0, game.players[0].minions[0].calculate_attack())
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual("Frog", game.players[0].minions[0].card.name)
        self.assertEqual(MINION_TYPE.BEAST,
                         game.players[0].minions[0].card.minion_type)
Exemple #44
0
    def test_DruidOfTheClaw(self):
        game = generate_game_for(DruidOfTheClaw, StonetuskBoar,
                                 MinionPlayingAgent, DoNothingBot)

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

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(4, game.current_player.minions[0].calculate_attack())
        self.assertEqual(4,
                         game.current_player.minions[0].calculate_max_health())
        self.assertTrue(game.current_player.minions[0].charge)
        self.assertFalse(game.current_player.minions[0].taunt)

        test_bear = game.current_player.minions[0].card.create_minion(None)
        test_bear.player = game.current_player
        self.assertEqual(4, test_bear.calculate_attack())
        self.assertEqual(4, test_bear.calculate_max_health())
        self.assertTrue(test_bear.charge)
        self.assertFalse(test_bear.taunt)

        game.current_player.agent.choose_option = lambda cat, bear: bear

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(2, len(game.current_player.minions))
        self.assertEqual(4, game.current_player.minions[0].calculate_attack())
        self.assertEqual(6,
                         game.current_player.minions[0].calculate_max_health())
        self.assertFalse(game.current_player.minions[0].charge)
        self.assertTrue(game.current_player.minions[0].taunt)

        test_bear = game.current_player.minions[0].card.create_minion(None)
        test_bear.player = game.current_player
        self.assertEqual(4, test_bear.calculate_attack())
        self.assertEqual(6, test_bear.calculate_max_health())
        self.assertFalse(test_bear.charge)
        self.assertTrue(test_bear.taunt)
Exemple #45
0
    def test_Polymorph(self):
        game = generate_game_for(MogushanWarden, Polymorph,
                                 OneCardPlayingAgent, CardTestingAgent)

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

        self.assertEqual(1, len(game.current_player.minions))
        self.assertTrue(game.current_player.minions[0].taunt)
        self.assertEqual(1, game.current_player.minions[0].calculate_attack())
        self.assertEqual(7, game.current_player.minions[0].health)
        self.assertEqual("Mogu'shan Warden",
                         game.current_player.minions[0].card.name)

        game.play_single_turn()
        self.assertEqual(1, len(game.other_player.minions))
        self.assertFalse(game.other_player.minions[0].taunt)
        self.assertEqual(1, game.other_player.minions[0].calculate_attack())
        self.assertEqual(1, game.other_player.minions[0].health)
        self.assertEqual("Sheep", game.other_player.minions[0].card.name)
        self.assertEqual(MINION_TYPE.BEAST,
                         game.other_player.minions[0].card.minion_type)
    def test_Jaraxxus(self):
        game = generate_game_for(LordJaraxxus, StonetuskBoar,
                                 PlayAndAttackAgent, DoNothingAgent)
        for turn in range(0, 17):
            game.play_single_turn()

        self.assertEqual(0, len(game.current_player.minions))
        self.assertEqual(15, game.current_player.hero.health)
        self.assertEqual(15, game.current_player.hero.calculate_max_health())
        self.assertEqual(27, game.other_player.hero.health)

        game.current_player.agent = PredictableAgent()

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(6, game.current_player.minions[0].calculate_attack())
        self.assertEqual(6,
                         game.current_player.minions[0].calculate_max_health())
        self.assertEqual(8, game.current_player.mana)
        self.assertEqual(24, game.other_player.hero.health)
Exemple #47
0
    def test_TempleEnforcer(self):
        game = generate_game_for([StonetuskBoar, TempleEnforcer],
                                 StonetuskBoar, MinionPlayingAgent,
                                 DoNothingBot)

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

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Stonetusk Boar",
                         game.players[0].minions[0].card.name)
        self.assertEqual(1, game.players[0].minions[0].health)
        self.assertEqual(1, game.players[0].minions[0].calculate_max_health())

        # Temple Enforcer should be played, targeting the Stonetusk Boar
        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual("Stonetusk Boar",
                         game.players[0].minions[1].card.name)
        self.assertEqual(4, game.players[0].minions[1].health)
        self.assertEqual(4, game.players[0].minions[1].calculate_max_health())
    def test_Jaraxxus_with_secrets(self):
        class SecretTester(DoNothingAgent):
            def __init__(self):
                super().__init__()
                self.turn = 0

            def do_turn(self, player):
                self.turn += 1
                if self.turn >= 8:
                    player.game.play_card(player.hand[0])

        game = generate_game_for(LordJaraxxus,
                                 [Repentance, Snipe, MirrorEntity],
                                 CardTestingAgent, SecretTester)

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

        # Jaraxxus should be played, Repentance should activate, leaving
        # the hero with one health and one max health
        # See http://www.reddit.com/r/hearthstone/comments/218vsu/jaraxxus_and_sword_of_justice_rule_inconsistency_o/

        self.assertEqual(1, game.current_player.hero.health)
        self.assertEqual(1, game.current_player.hero.calculate_max_health())

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(11, game.current_player.hero.health)
        self.assertEqual(15, game.current_player.hero.calculate_max_health())

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(15, game.current_player.hero.health)
        self.assertEqual(15, game.current_player.hero.calculate_max_health())
        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual("Lord Jaraxxus",
                         game.other_player.minions[0].card.name)
Exemple #49
0
    def test_Maexxna_and_EmperorCobra(self):
        game = generate_game_for([Maexxna, EmperorCobra], FacelessManipulator,
                                 PredictableAgentWithoutHeroPower,
                                 create_enemy_copying_agent(6))
        for turn in range(0, 13):
            game.play_single_turn()

        # The faceless should have copied Maexxna, then the following turn
        # Maexxna should attack the copy, resulting in both dying.  All that should
        # be left is the cobra played this turn

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual("Emperor Cobra",
                         game.current_player.minions[0].card.name)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual("Maexxna", game.current_player.minions[0].card.name)
    def test_Duplicate_and_play_after(self):
        game = generate_game_for([Wisp, Wisp, Wisp, Wisp, Wisp, Duplicate],
                                 LightningStorm, CardTestingAgent,
                                 OneCardPlayingAgent)

        for turn in range(5):
            game.play_single_turn()

        self.assertEqual(0, len(game.current_player.hand))
        self.assertEqual(5, len(game.current_player.minions))
        self.assertEqual(1, len(game.current_player.secrets))

        game.play_single_turn()

        self.assertEqual(0, len(game.other_player.secrets))
        self.assertEqual(0, len(game.other_player.minions))
        self.assertEqual(2, len(game.other_player.hand))

        game.play_single_turn()

        self.assertEqual(0, len(game.current_player.hand))
        self.assertEqual(3, len(game.current_player.minions))
    def test_Spellbender_target_hero_and_attack(self):
        game = generate_game_for([Spellbender, OasisSnapjaw],
                                 [LavaBurst, Wisp, Loatheb],
                                 OneCardPlayingAgent, PlayAndAttackAgent)

        for turn in range(5):
            game.play_single_turn()
        self.assertEqual(1, len(game.current_player.secrets))
        self.assertEqual(0, len(game.other_player.minions))
        game.play_single_turn()

        self.assertEqual(1, len(game.other_player.secrets))
        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual(25, game.other_player.hero.health)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(25, game.other_player.hero.health)
        self.assertEqual(1, len(game.other_player.minions))
        self.assertEqual(6, game.other_player.minions[0].health)
        self.assertEqual(1, len(game.other_player.secrets))
Exemple #52
0
    def test_BattleRage(self):
        game = generate_game_for(BattleRage, StonetuskBoar, CardTestingAgent,
                                 DoNothingAgent)

        game.players[0].mana = 100

        shield = Shieldbearer()
        shield.use(game.players[0], game)
        shield.use(game.players[0], game)
        shield.use(game.players[0], game)
        game.players[0].minions[0].damage(1, None)
        game.players[0].minions[1].damage(1, None)
        game.players[0].hero.damage(1, None)

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

        self.assertEqual(4, len(game.players[0].hand))

        # Battle Rage should be played, 3 damaged characters = 3 cards drawn
        game.play_single_turn()
        self.assertEqual(7, len(game.players[0].hand))
    def test_PoisonSeeds(self):
        game = generate_game_for(
            [StonetuskBoar, BloodfenRaptor, IronfurGrizzly, PoisonSeeds],
            HauntedCreeper, OneCardPlayingAgent, OneCardPlayingAgent)

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

        self.assertEqual(2, len(game.current_player.minions))
        self.assertEqual(3, len(game.other_player.minions))

        game.play_single_turn()

        self.assertEqual(3, len(game.current_player.minions))
        self.assertEqual(6, len(game.other_player.minions))

        for minion in game.current_player.minions:
            self.assertEqual("Treant", minion.card.name)
            self.assertEqual(2, minion.calculate_attack())
            self.assertEqual(2, minion.calculate_max_health())

        for index in range(0, 4):
            self.assertEqual("Spectral Spider",
                             game.other_player.minions[index].card.name)
            self.assertEqual(
                1, game.other_player.minions[index].calculate_attack())
            self.assertEqual(
                1, game.other_player.minions[index].calculate_max_health())

        self.assertEqual("Treant", game.other_player.minions[4].card.name)
        self.assertEqual(2, game.other_player.minions[4].calculate_attack())
        self.assertEqual(2,
                         game.other_player.minions[4].calculate_max_health())

        self.assertEqual("Treant", game.other_player.minions[5].card.name)
        self.assertEqual(2, game.other_player.minions[5].calculate_attack())
        self.assertEqual(2,
                         game.other_player.minions[5].calculate_max_health())
Exemple #54
0
    def test_AuchenaiSoulpriest(self):
        game = generate_game_for([AuchenaiSoulpriest, EarthenRingFarseer], StonetuskBoar,
                                 OneCardPlayingAgent, DoNothingAgent)

        # Auchenai Soulpriest should be played
        for turn in range(0, 7):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Auchenai Soulpriest", game.players[0].minions[0].card.name)
        self.assertTrue(game.players[0].heal_does_damage)

        # ERF will damage the Soulpriest with its battlecry

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual("Earthen Ring Farseer", game.players[0].minions[0].card.name)
        self.assertEqual(3, game.players[0].minions[0].health)
        self.assertEqual(2, game.players[0].minions[1].health)

        game.play_single_turn()
        game.play_single_turn()

        game.players[0].minions[2].silence()
        self.assertTrue(game.players[0].heal_does_damage)
        soulpriest = game.players[0].minions[0]
        soulpriest.die(None)
        game.check_delayed()
        self.assertFalse(game.players[0].heal_does_damage)

        game.play_single_turn()
        # ERF should heal again
        game.play_single_turn()

        # This minion should not have taken damage and received heal instead
        self.assertEqual(3, game.players[0].minions[1].health)
Exemple #55
0
    def test_BladeFlurry(self):
        game = generate_game_for(Shieldbearer, BladeFlurry,
                                 OneCardPlayingAgent, PredictableAgent)

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

        self.assertEqual(4, len(game.players[0].minions))
        self.assertEqual(30, game.players[0].hero.health)
        self.assertEqual(4, game.players[0].minions[0].health)
        self.assertEqual(3, game.players[0].minions[1].health)
        self.assertEqual(3, game.players[0].minions[2].health)
        self.assertEqual(4, game.players[0].minions[3].health)

        # An attack with our knife should first happen, and then should Blade Flurry be played, destroying our knife
        # and dealing 1 damage to all enemy minions
        game.play_single_turn()
        self.assertEqual(4, len(game.players[0].minions))
        self.assertEqual(29, game.players[0].hero.health)
        self.assertEqual(2, game.players[0].minions[0].health)
        self.assertEqual(2, game.players[0].minions[1].health)
        self.assertEqual(2, game.players[0].minions[2].health)
        self.assertEqual(3, game.players[0].minions[3].health)
    def test_LayOnHands(self):
        game = generate_game_for(StonetuskBoar, LayOnHands, DoNothingAgent,
                                 CardTestingAgent)

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

        game.players[0].hero.health = 20
        # Put back some cards from hand, for testing purpose
        for putback in range(0, 4):
            card = game.players[1].hand.pop()
            game.players[1].put_back(card)
        game.players[1].put_back(game.players[1].hand[1])
        game.players[1].hand.remove(game.players[1].hand[1])
        self.assertEqual(5, len(game.players[1].hand))
        game.play_single_turn()  # Lay on Hands should be played
        self.assertEqual(28, game.players[0].hero.health)
        self.assertEqual(8, len(game.players[1].hand))
        game.play_single_turn()
        game.play_single_turn(
        )  # Lay on Hands should be played, and a card be discarded since we have 8 already
        self.assertEqual(30, game.players[0].hero.health)
        self.assertEqual(10, len(game.players[1].hand))
    def test_NobleSacrifice(self):
        game = generate_game_for(NobleSacrifice, StonetuskBoar,
                                 CardTestingAgent, PlayAndAttackAgent)

        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].hero.health)

        # Test with 7 minions
        game = playback(
            Replay("tests/replays/card_tests/NobleSacrifice.hsreplay"))
        game.start()
        self.assertEqual(7, len(game.players[0].minions))
        self.assertEqual(29, game.players[0].hero.health)
        self.assertEqual(1, len(game.players[0].secrets))
        self.assertEqual("Noble Sacrifice", game.players[0].secrets[0].name)
Exemple #58
0
    def test_ManaTideTotem(self):
        game = generate_game_for([ManaTideTotem, WarGolem], StonetuskBoar,
                                 OneCardPlayingAgent, DoNothingAgent)

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

        self.assertEqual(25, game.players[0].deck.left)
        self.assertEqual(0, len(game.players[0].minions))

        # Mana Tide Totem should be played, and we should draw a card at the end of turn
        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual("Mana Tide Totem",
                         game.players[0].minions[0].card.name)
        self.assertEqual(23, game.players[0].deck.left)

        game.play_single_turn()
        # Silence, we should only draw one card next turn
        game.players[0].minions[0].silence()
        game.play_single_turn()
        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(22, game.players[0].deck.left)
Exemple #59
0
    def test_ArcaneMissiles(self):
        game = generate_game_for(MogushanWarden, ArcaneMissiles,
                                 OneCardPlayingAgent, CardTestingAgent)

        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(27, game.other_player.hero.health)

        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()
        game.play_single_turn()

        self.assertEqual(1, len(game.current_player.minions))
        self.assertEqual("Mogu'shan Warden",
                         game.current_player.minions[0].card.name)

        game.play_single_turn()
        # The random numbers work so that the arcane missiles hit thrice on each target
        self.assertEqual(9, game.other_player.hero.health)
        self.assertEqual(4, game.other_player.minions[0].health)
Exemple #60
0
    def test_DarkIronskulker(self):
        game = generate_game_for(DarkIronSkulker, ChillwindYeti,
                                 OneCardPlayingAgent, OneCardPlayingAgent)
        for turn in range(0, 10):
            game.play_single_turn()

        self.assertEqual(1, len(game.players[0].minions))
        self.assertEqual(2, len(game.players[1].minions))
        self.assertEqual(3, game.players[0].minions[0].health)
        self.assertEqual(5, game.players[1].minions[0].health)
        self.assertEqual(
            3, game.players[1].minions[1].health)  # Damages full HP Yeti

        game.play_single_turn()

        self.assertEqual(2, len(game.players[0].minions))
        self.assertEqual(2, len(game.players[1].minions))
        self.assertEqual(3, game.players[0].minions[0].health)
        self.assertEqual(
            3, game.players[0].minions[1].health)  # Does not damage friendly
        self.assertEqual(3, game.players[1].minions[0].health)
        self.assertEqual(3, game.players[1].minions[1].health
                         )  # Does not damage already damaged Yeti