def pool_with_same_value_card(): """setting pool with some same value cards.""" player1, player2 = Player('Player1', Hand()), Player('Player2', Hand()) player1.hand.cards = [ Card('D', 'A'), Card('D', '8'), Card('H', '3'), Card('S', '9'), Card('C', 'Q') ] player2.hand.cards = [ Card('H', 'A'), Card('C', 'J'), Card('H', '2'), Card('S', '2'), Card('S', 'A') ] pool = Pool() pool.add_card(player1.hand.take_top(), player1) pool.add_card(player2.hand.take_top(), player2) pool.add_bonus([ player1.hand.take_top(), player1.hand.take_top(), player1.hand.take_top(), player2.hand.take_top(), player2.hand.take_top(), player2.hand.take_top() ]) pool.add_card(player1.hand.take_top(), player1) pool.add_card(player2.hand.take_top(), player2) return pool
def test_player_drop_card_empty_hand(): """Empty hand drop card to pool.""" player1 = Player('Player1', Hand()) pool = Pool() player1.drop_card(pool) assert len(pool.cards) == 0 assert len(player1.hand.cards) == 0
def test_player_drop_bonus_have_less_than_3_cards(): """Player drops number of cards in hand to bonus bucket, when hand has less than 3 cards.""" player1 = Player('Player1', Hand()) player1.hand.cards = [Card('D', 'A'), Card('D', '8')] pool = Pool() player1.drop_bonus(pool, 3) assert len(player1.hand.cards) == 0 assert len(pool.bonus) == 2
def test_deck_setup_hands_for_2_gives_26_each(): """For 2 player each has 26 cards in their hand""" deck = Deck() player1 = Player('player1', Hand()) player2 = Player('player2', Hand()) players = [player1, player2] deck.setup_hands(players) assert len(player1.hand.cards) == 26 assert len(player2.hand.cards) == 26
def pool_with_diff_value_card(): """setting pool with different value cards.""" card1, card2 = Card('D', '5'), Card('S', '8') player1, player2 = Player('Player1', Hand()), Player('Player2', Hand()) player1.hand.add_card(card1) player2.hand.add_card(card2) pool = Pool() pool.add_card(player1.hand.take_top(), player1) pool.add_card(player2.hand.take_top(), player2) return pool
def test_pool_winner_cards_value_same(): """Pool winner is None when card value same""" player1 = Player('Player1', Hand()) card1 = Card('D', '5') player2 = Player('Player2', Hand()) card2 = Card('S', '5') pool = Pool() pool.add_card(card1, player1) pool.add_card(card2, player2) assert pool.winner is None
def test_pool_winner_cards_value_differ(): """Pool winner when card value differ""" player1 = Player('Player1', Hand()) card1 = Card('D', '5') player2 = Player('Player2', Hand()) card2 = Card('S', '8') pool = Pool() pool.add_card(card1, player1) pool.add_card(card2, player2) assert pool.winner.name == 'Player2'
def test_pool_add_bonus_when_tie(): """Adding cards to bonus bucket of pool.""" player1 = Player('Player1', Hand()) card1 = Card('D', '5') player2 = Player('Player2', Hand()) card2 = Card('C', '5') pool = Pool() pool.add_card(card1, player1) pool.add_card(card2, player2) cards = [Card('H', '6'), Card('S', '8'), Card('D', '6')] pool.add_bonus(cards) assert len(pool.bonus) == len(cards)
def test_deck_setup_hands_for_4_gives_13_each(): """For 4 player each has 13 cards in their hand""" deck = Deck() player1 = Player('player1', Hand()) player2 = Player('player2', Hand()) player3 = Player('player3', Hand()) player4 = Player('player4', Hand()) players = [player1, player2, player3, player4] deck.setup_hands(players) assert len(player1.hand.cards) == 13 assert len(player2.hand.cards) == 13 assert len(player3.hand.cards) == 13 assert len(player4.hand.cards) == 13
def test_pool_add_card_multiple(): """ Adding multiple cards to pool using add_card """ player1 = Player('Player1', Hand()) card1 = Card('D', 'A') player2 = Player('Player2', Hand()) card2 = Card('C', '5') player3 = Player('Player3', Hand()) card3 = Card('S', '10') pool = Pool() pool.add_card(card1, player1) pool.add_card(card2, player2) pool.add_card(card3, player3) assert str(pool) == '[D-A :: Player1, C-5 :: Player2, S-10 :: Player3]'
def test_pool_add_card_1(): """Adding 1 card to pool""" player1 = Player('Player1', Hand()) card1 = Card('D', 'A') pool = Pool() pool.add_card(card1, player1) assert str(pool) == '[D-A :: Player1]'
def __init__(self, players): """ Initialize the game with Players as input. @param players: A list of 2 players. """ self.players = [Player(name, Hand()) for name in players] self.deck = Deck() self.rounds = 0
def test_deck_setup_hands_makes_empty(): """Check if all the cards are distributed. By check deck len = 0""" deck = Deck() players = [Player(name, Hand()) for name in ['player1', 'player2']] deck.setup_hands(players) assert len(deck.cards) == 0
def players(): """ Setting a players of 2""" player1, player2 = Player('Player1', Hand()), Player('Player2', Hand()) player1.hand.cards = [Card('D', 'A'), Card('D', '8'), Card('H', '3'), Card('S', '9'), Card('C', 'Q')] player2.hand.cards = [Card('H', 'A'), Card('C', 'J'), Card('H', '2'), Card('S', '2'), Card('S', 'A')] return [player1, player2]