def test_make_deck(self): hand = standard.StandardHand() for suit in standard.SUITS: for rank in standard.RANKS: hand.append(standard.StandardCard(rank, suit)) deck = standard.make_deck() self.assertEqual(deck, hand)
def setUp(self): score = {"fifteens": 0, "pairs": 0, "runs": 0, "flush": 0, "heels": 0, "nobs": 0} self.deck = standard.make_deck() self.dscore = score.copy() self.dscore.update({"fifteens": 34528, "runs": 872415232, "pairs": 156}) self.spades = self.deck.by_suit(standard.SPADE) self.sscore = score.copy() self.sscore.update({"fifteens": 58, "runs": 13, "pairs": 0, "flush": 13})
def setUp(self): score = { "fifteens": 0, "pairs": 0, "runs": 0, "flush": 0, "heels": 0, "nobs": 0 } self.deck = standard.make_deck() self.dscore = score.copy() self.dscore.update({ "fifteens": 34528, "runs": 872415232, "pairs": 156 }) self.spades = self.deck.by_suit(standard.SPADE) self.sscore = score.copy() self.sscore.update({ "fifteens": 58, "runs": 13, "pairs": 0, "flush": 13 })
if turned and dealer and turned.rank == standard.JACK: score["heels"] = 2 elif turned and standard.StandardCard(standard.JACK, turned.suit) in hand: score["nobs"] = 1 return score if __name__ == "__main__": from random import getrandbits def rand_bool(): return not getrandbits(1) deck = standard.make_deck(shuffle = True) hand = deck.deal(4) turned = deck.pop() dealing = rand_bool() cribbing = rand_bool() score = score_hand(hand, turned=turned, dealer=dealing, crib=cribbing) if dealing: print "dealing." if cribbing: print "counting crib." print "turned:", turned print hand print
def test_make_deck_shuffle(self): random.seed(0) unshuffled = standard.make_deck(shuffle=False) shuffled = standard.make_deck(shuffle=True) self.assertNotEqual(unshuffled, shuffled)
def test_hand_by_rank(self): aces = standard.make_deck().by_rank(standard.ACE) self.assertEqual(str(aces), "As Ah Ad Ac")
def test_hand_by_suit(self): spades = standard.make_deck().by_suit(standard.SPADE) self.assertEqual(str(spades), "AKQJT98765432s")
def test_hand_str(self): deck = standard.make_deck() self.assertEqual(str(deck), "AKQJT98765432s AKQJT98765432h " "AKQJT98765432d AKQJT98765432c")
def test_hand_str(self): deck = standard.make_deck() self.assertEqual( str(deck), "AKQJT98765432s AKQJT98765432h " "AKQJT98765432d AKQJT98765432c")
if turned and dealer and turned.rank == standard.JACK: score["heels"] = 2 elif turned and standard.StandardCard(standard.JACK, turned.suit) in hand: score["nobs"] = 1 return score if __name__ == "__main__": from random import getrandbits def rand_bool(): return not getrandbits(1) deck = standard.make_deck(shuffle=True) hand = deck.deal(4) turned = deck.pop() dealing = rand_bool() cribbing = rand_bool() score = score_hand(hand, turned=turned, dealer=dealing, crib=cribbing) if dealing: print "dealing." if cribbing: print "counting crib." print "turned:", turned print hand print