예제 #1
0
    def test_deck_deal(self):
        d = Deck()

        c = d.deal()
        self.assertFalse(d.contains(c))

        d2 = Deck()
        self.assertTrue(d2.contains(c))
예제 #2
0
    def test_deck_deal(self):
        d = Deck()

        c = d.deal()
        self.assertFalse(d.contains(c))

        d2 = Deck()
        self.assertTrue(d2.contains(c))
예제 #3
0
    def test_deck_contains_ace_of_hearts(self):
        d = Deck()
        c = Card('Hearts', 'Ace')

        self.assertTrue(d.contains(c))
예제 #4
0
 def test_init_jokers(self):
     d = Deck(jokers=2)
     self.assertEqual(len(d.cards), 54)
     self.assertTrue(d.contains(Card('Wild', 'Joker')))
예제 #5
0
 def test_init(self):
     d = Deck(jokers=False)
     self.assertEqual(len(d.cards), 52)
     self.assertFalse(d.contains(Card('Wild', 'Joker')))
예제 #6
0
파일: demo.py 프로젝트: Ropes/SQL-n-Knaves
from cards.deck import Deck

random.seed(5)

def get_cards(deck, number):
    return [ deck.deal() for i in range(number) ]

if __name__ == '__main__':
    d = Deck(jokers=2)
    print(unicode(d))

    #Shuffle the deck again
    d.shuffle()
    print("\nPost shuffling again:")
    print(unicode(d))

    #Get a hand of cards from the deck
    print('\nDealt Hand:')
    hand = get_cards(d, 5)
    for c in hand:
        print(unicode(c))

    #Make sure one of the cards dealt is no longer in the deck
    check_card = hand[1]
    print('\n{} in deck? {}'.format(unicode(check_card),\
                                    d.contains(check_card)))

    #Check if a card is still in the deck
    print('\nJoker in deck? {}'.format(d.contains(Card('Wild', 'Joker'))))

예제 #7
0
    def test_deck_contains_ace_of_hearts(self):
        d = Deck()
        c = Card('Hearts', 'Ace')

        self.assertTrue(d.contains(c))
예제 #8
0
 def test_init_jokers(self):
     d = Deck(jokers=2)
     self.assertEqual(len(d.cards), 54)
     self.assertTrue(d.contains(Card('Wild', 'Joker')))
예제 #9
0
 def test_init(self):
     d = Deck(jokers=False)
     self.assertEqual(len(d.cards), 52)
     self.assertFalse(d.contains(Card('Wild', 'Joker')))
예제 #10
0
파일: demo.py 프로젝트: Ropes/SQL-n-Knaves
random.seed(5)


def get_cards(deck, number):
    return [deck.deal() for i in range(number)]


if __name__ == '__main__':
    d = Deck(jokers=2)
    print(unicode(d))

    #Shuffle the deck again
    d.shuffle()
    print("\nPost shuffling again:")
    print(unicode(d))

    #Get a hand of cards from the deck
    print('\nDealt Hand:')
    hand = get_cards(d, 5)
    for c in hand:
        print(unicode(c))

    #Make sure one of the cards dealt is no longer in the deck
    check_card = hand[1]
    print('\n{} in deck? {}'.format(unicode(check_card),\
                                    d.contains(check_card)))

    #Check if a card is still in the deck
    print('\nJoker in deck? {}'.format(d.contains(Card('Wild', 'Joker'))))