def test_Swipe(self): deck1 = StackedDeck([BloodfenRaptor(), StonetuskBoar(), StonetuskBoar()],CHARACTER_CLASS.DRUID) deck2 = StackedDeck([Swipe()], CHARACTER_CLASS.DRUID,) game = Game([deck1, deck2], [MinionPlayingAgent(), EnemyMinionSpellTestingAgent()]) game.pre_game() game.current_player = game.players[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() spell_damage_mock = Mock() game.current_player.minions[0].bind('spell_damaged', spell_damage_mock) game.current_player.minions[1].bind('spell_damaged', spell_damage_mock) game.current_player.minions[2].bind('spell_damaged', spell_damage_mock) swipe_card = game.other_player.hand[0] game.play_single_turn() self.assertListEqual([call(4, swipe_card), call(1, swipe_card), call(1, swipe_card)], spell_damage_mock.call_args_list) #The bloodfen raptor should be left, with one hp self.assertEqual(1, len(game.other_player.minions)) self.assertEqual(1, game.other_player.minions[0].health) self.assertEqual(29, game.other_player.health)
def test_CircleOfHealing(self): deck1 = StackedDeck([CircleOfHealing(), MogushanWarden(), CircleOfHealing(), CircleOfHealing(), CircleOfHealing(), CircleOfHealing(), CircleOfHealing()], CHARACTER_CLASS.PRIEST) deck2 = StackedDeck([MogushanWarden()], CHARACTER_CLASS.PALADIN) game = Game([deck1, deck2], [SpellTestingAgent(), MinionPlayingAgent()]) game.pre_game() game.current_player = 1 for turn in range(0, 8): game.play_single_turn() game.players[0].minions[0].defense = 4 game.players[1].minions[0].defense = 4 game.play_single_turn() # Circle of Healing should be played self.assertEqual(game.players[0].minions[0].max_defense, game.players[0].minions[0].defense) self.assertEqual(game.players[1].minions[0].max_defense, game.players[1].minions[0].defense)
def test_HolyNova(self): deck1 = StackedDeck([MogushanWarden(), HolyNova()], CHARACTER_CLASS.PRIEST) deck2 = StackedDeck([MogushanWarden()], CHARACTER_CLASS.PALADIN) game = Game([deck1, deck2], [SpellTestingAgent(), MinionPlayingAgent()]) game.pre_game() game.current_player = 1 for turn in range(0, 8): game.play_single_turn() self.assertEqual(1, len(game.players[0].minions)) self.assertEqual(1, len(game.players[1].minions)) game.players[0].minions[0].health = 4 # Fake damage self.assertEqual(4, game.players[0].minions[0].health) self.assertEqual(7, game.players[1].minions[0].health) game.play_single_turn() # Holy Nova should be played self.assertEqual(6, game.players[0].minions[0].health) self.assertEqual(5, game.players[1].minions[0].health)
def test_SorcerersApprentice(self): deck1 = StackedDeck([SorcerersApprentice(), ArcaneMissiles(), SorcerersApprentice(), Frostbolt(), Frostbolt(), Frostbolt()], CHARACTER_CLASS.MAGE) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.PRIEST) game = Game([deck1, deck2], [SpellTestingAgent(), DoNothingBot()]) game.pre_game() game.current_player = game.players[1] 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(game.current_player)) self.assertEqual(1, game.current_player.hand[2].mana_cost(game.current_player)) game.play_single_turn() game.play_single_turn() # Both Sorcer'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)
def test_ManaWyrm(self): deck1 = StackedDeck([ManaWyrm(), IceLance(), ManaWyrm(), IceLance(), IceLance(), IceLance()], CHARACTER_CLASS.MAGE) deck2 = StackedDeck([IronbeakOwl()], CHARACTER_CLASS.PALADIN) game = Game([deck1, deck2], [SpellTestingAgent(), MinionPlayingAgent()]) game.pre_game() game.current_player = 1 game.play_single_turn() self.assertEqual(1, len(game.current_player.minions)) self.assertEqual(1, game.current_player.minions[0].calculate_attack()) self.assertEqual(3, game.current_player.minions[0].health) self.assertEqual(3, game.current_player.minions[0].calculate_max_health()) self.assertEqual("Mana Wyrm", game.current_player.minions[0].card.name) game.play_single_turn() game.play_single_turn() self.assertEqual(2, len(game.current_player.minions)) self.assertEqual(1, game.current_player.minions[0].calculate_attack()) self.assertEqual(3, game.current_player.minions[0].health) self.assertEqual(3, game.current_player.minions[0].calculate_max_health()) self.assertEqual(2, game.current_player.minions[1].calculate_attack()) self.assertEqual(3, game.current_player.minions[1].health) self.assertEqual(3, game.current_player.minions[1].calculate_max_health()) game.play_single_turn() game.play_single_turn() self.assertEqual(2, len(game.current_player.minions)) self.assertEqual(1, game.current_player.minions[0].calculate_attack()) self.assertEqual(3, game.current_player.minions[0].health) self.assertEqual(3, game.current_player.minions[0].calculate_max_health()) self.assertEqual(5, game.current_player.minions[1].calculate_attack()) self.assertEqual(3, game.current_player.minions[1].health) self.assertEqual(3, game.current_player.minions[1].calculate_max_health())
def test_SavageRoar(self): deck1 = StackedDeck([StonetuskBoar(), StonetuskBoar(), SavageRoar()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.MAGE) game = Game([deck1, deck2], [MinionPlayingAgent(), MinionPlayingAgent()]) game.current_player = 1 game.play_single_turn() game.play_single_turn() game.play_single_turn() game.play_single_turn() minion_increase_mock = Mock() game.other_player.minions[0].bind("attack_increased", minion_increase_mock) game.other_player.minions[1].bind("attack_increased", minion_increase_mock) player_increase_mock = Mock() game.other_player.bind("attack_increased", player_increase_mock) game.play_single_turn() self.assertEqual(0, game.current_player.mana) #Make sure the attack got increased self.assertListEqual([call(2), call(2)], minion_increase_mock.call_args_list) self.assertListEqual([call(2)], player_increase_mock.call_args_list) #And make sure that it went down again self.assertEqual(0, game.current_player.minions[0].temp_attack) self.assertEqual(0, game.current_player.minions[1].temp_attack) self.assertEqual(0, game.current_player.attack_power)
def test_ClawAndSavagery(self): deck1 = StackedDeck([BloodfenRaptor()], CHARACTER_CLASS.PRIEST) deck2 = StackedDeck([Claw(), Claw(), Savagery()], CHARACTER_CLASS.DRUID) game = Game([deck1, deck2], [MinionPlayingAgent(), EnemyMinionSpellTestingAgent()]) game.current_player = game.players[1] game.pre_game() game.play_single_turn() 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))
def test_PowerOfTheWild(self): deck1 = StackedDeck([StonetuskBoar(), StonetuskBoar(), PowerOfTheWild()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.MAGE) #This is a test of the +1/+1 option of the Power Of the Wild Card game = Game([deck1, deck2], [MinionPlayingAgent(), MinionPlayingAgent()]) game.current_player = game.players[1] game.play_single_turn() game.play_single_turn() game.play_single_turn() game.play_single_turn() game.play_single_turn() self.assertEqual(2, game.current_player.minions[0].attack_power) self.assertEqual(2, game.current_player.minions[0].health) self.assertEqual(2, game.current_player.minions[0].max_health) self.assertEqual(2, game.current_player.minions[1].attack_power) self.assertEqual(2, game.current_player.minions[1].max_health) #This is a test of the "Summon Panther" option of the Power of the Wild Card agent = MinionPlayingAgent() agent.choose_option = Mock(side_effect=lambda *options: options[1]) deck1 = StackedDeck([StonetuskBoar(), StonetuskBoar(), PowerOfTheWild()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.MAGE) game = Game([deck1, deck2], [agent, MinionPlayingAgent()]) game.current_player = game.players[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.assertEqual("Panther", game.current_player.minions[2].card.__class__.__name__) self.assertEqual(3, game.current_player.minions[2].attack_power) self.assertEqual(2, game.current_player.minions[2].max_health)
def test_Cenarius(self): deck1 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([WarGolem(), WarGolem(), Cenarius(), Cenarius()], CHARACTER_CLASS.DRUID) game = Game([deck1, deck2], [DoNothingBot(), MinionPlayingAgent()]) game.pre_game() 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() game.play_single_turn() game.play_single_turn() game.play_single_turn() self.assertEqual(2, len(game.other_player.minions)) for minion in game.other_player.minions: self.assertEqual(7, minion.attack_power) self.assertEqual(7, minion.health) self.assertEqual(7, minion.max_health) game.play_single_turn() self.assertEqual(3, len(game.current_player.minions)) self.assertEqual(5, game.current_player.minions[0].attack_power) self.assertEqual(8, game.current_player.minions[0].health) self.assertEqual(8, game.current_player.minions[0].max_health) self.assertEqual("Cenarius", game.current_player.minions[0].card.name) for minion_index in range(1, 3): minion = game.current_player.minions[minion_index] self.assertEqual(9, minion.attack_power) self.assertEqual(9, minion.health) self.assertEqual(9, minion.max_health) game.players[1].agent.choose_option = Mock(side_effect=lambda stats, summon: summon) game.play_single_turn() game.play_single_turn() self.assertEqual(6, len(game.current_player.minions)) self.assertEqual(5, game.current_player.minions[0].attack_power) self.assertEqual(8, game.current_player.minions[0].health) self.assertEqual(8, game.current_player.minions[0].max_health) self.assertEqual("Cenarius", game.current_player.minions[0].card.name) self.assertEqual(2, game.current_player.minions[1].attack_power) self.assertEqual(2, game.current_player.minions[1].health) self.assertEqual(2, game.current_player.minions[1].max_health) self.assertTrue(game.current_player.minions[1].taunt) self.assertEqual("Treant", game.current_player.minions[1].card.name) self.assertEqual(2, game.current_player.minions[2].attack_power) self.assertEqual(2, game.current_player.minions[2].health) self.assertEqual(2, game.current_player.minions[2].max_health) self.assertTrue(game.current_player.minions[2].taunt) self.assertEqual("Treant", game.current_player.minions[2].card.name)
def test_MarkOfNature(self): deck1 = StackedDeck([StonetuskBoar(), StonetuskBoar(), MarkOfNature()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.MAGE) game = Game([deck1, deck2], [MinionPlayingAgent(), MinionPlayingAgent()]) game.current_player = 1 game.play_single_turn() game.play_single_turn() game.play_single_turn() game.play_single_turn() game.play_single_turn() self.assertEqual(5, game.other_player.minions[0].attack_power) def mock_choose(*options): return options[1] deck1 = StackedDeck([StonetuskBoar(), StonetuskBoar(), MarkOfNature()], CHARACTER_CLASS.DRUID) deck2 = StackedDeck([StonetuskBoar()], CHARACTER_CLASS.MAGE) agent = MinionPlayingAgent() agent.choose_option = Mock(side_effect=mock_choose) game = Game([deck1, deck2], [agent, MinionPlayingAgent()]) game.current_player = 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.assertEqual(5, game.other_player.minions[0].max_health) self.assertEqual(5, game.other_player.minions[0].health) self.assertTrue(game.other_player.minions[0].taunt)