def test_player_can_play_card_if_hasnt_mana(self): deck = MagicMock(name='Deck') mana_cost = random.randint(1111, 9999) card = {'mana': mana_cost} deck.pick.return_value = card player = Player(None) player.add_deck(deck) player.add_mana(mana_cost - 1) player.draw_card() self.assertEqual(0, player.play_cards()) deck.pick.assert_called_once_with()
def test_player_can_play_card_when_has_mana(self): deck = MagicMock(name='Deck') card1 = {'mana': 1, 'damage': 1} card2 = {'mana': 2, 'damage': 2} deck.pick.side_effect = [card1, card2] player = Player(None) player.add_deck(deck) player.add_mana(3) player.draw_card() player.draw_card() self.assertEqual(3, player.play_cards())
def test_draw_card_from_deck(self): deck = MagicMock(name='Deck') card = {'mana': random.randint(1111, 9999)} deck.pick.return_value = card player = Player(None) player.add_deck(deck) player.draw_card() deck.pick.assert_called_once_with() self.assertEqual(1, player.get_hand_card_number())
from app.game import Game from app.object.player import Player from app.object.deck import Deck deck_one = Deck.generate([0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8]) deck_two = Deck.generate([0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8]) player_one = Player(20) player_one.add_deck(deck_one) player_one.shuffle_deck() player_two = Player(20) player_two.add_deck(deck_two) player_two.shuffle_deck() game = Game(player_one, player_two) winner = game.play_game() + 1 print(winner)
def test_get_life_point(self): life_point = random.randint(1111, 9999) player = Player(life_point) self.assertEqual(life_point, player.get_life_point())
def test_shuffle_deck(self): deck = MagicMock(name='Deck') player = Player(None) player.add_deck(deck) player.shuffle_deck() deck.card_shuffle.assert_called_once_with(random.shuffle)
def add_mana(self): player = Player(None) player.add_mana(1) self.assertEqual(1, player.get_mana())
def test_no_deck_draw(self): player = Player(20) self.assertFalse(player.draw_card())
def test_damage(self): player = Player(20) self.assertEqual(15, player.receive_damage(5).get_life_point())