Ejemplo n.º 1
0
 def test_shuffle_deck(self):
     deck = Deck()
     deck.shuffle()
     card1 = Card(Rank.ACE, Suit.SPADES)
     card2 = Card(Rank.TWO, Suit.SPADES)
     card1_shuffled = deck._cards[0] is not card1
     card2_shuffled = deck._cards[1] is not card2
     # Extremely unlikely to fail, but can happen
     self.assertTrue(card1_shuffled or card2_shuffled)
Ejemplo n.º 2
0
 def setup(self) -> None:
     """Set up the game by dealing the player and the house two cards each.
     """
     self.deck = Deck()
     self.deck.shuffle()
     self.user.add_to_hand(self.deck.draw())
     self.house.add_to_hand(self.deck.draw())
     self.user.add_to_hand(self.deck.draw())
     self.house.add_to_hand(self.deck.draw())
Ejemplo n.º 3
0
    def test_new_double_deck(self):
        deck = Deck(2)
        self.assertEqual(deck.size(), 2 * _DECK_SZ)

        as_card = Card(Rank.ACE, Suit.SPADES)
        as_count = 0
        for card in deck._cards:
            if card == as_card:
                as_count += 1
        self.assertEqual(as_count, 2)
Ejemplo n.º 4
0
    def setup_round(self, num_players: int):
        """Set up the game by making a deck, shuffling it, dealing cards,
        making a discard, flipping over the top card, and creating the
        round points.

        Args:
            num_players (int): number of players

        Returns:
            CrazyEights: game after the setup is complete
        """
        for player in self.players.values():
            player.clear_hand()  # empty the players' hands from prev rounds
        num_decks = 2 if len(self.players) > 5 else 1
        self.deck = Deck(num_decks)
        self.deck.shuffle()
        num_cards = 5 if len(self.players) > 2 else 7
        self.deal(num_cards)
        self.discard = []
        self.discard.append(self.deck.draw())
        self.pts = [0] * num_players