def test_HasFlush_three_card_non_flush(self): s = scoring.HasFlush() hand = [ pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['nine']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['jack']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['two']) ] score, _ = s.check(hand) self.assertEqual(score, 0)
def test_HasFlush_four_card_flush(self): s = scoring.HasFlush() hand = [ pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['nine']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['ace']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['five']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['jack']) ] score, _ = s.check(hand) self.assertEqual(score, 4)
def test_HasFlush_four_card_old_flush(self): """Tests to make sure latest card must be part of flush""" s = scoring.HasFlush() hand = [ pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['nine']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['ace']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['five']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['jack']), pc.Card(suit=pc.Deck.SUITS['diamonds'], rank=pc.Deck.RANKS['two']) ] score, _ = s.check(hand) self.assertEqual(score, 0)
def test_HasFlush_five_card_split_flush(self): s = scoring.HasFlush() hand = [ pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['nine']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['ace']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['king']), pc.Card(suit=pc.Deck.SUITS['clubs'], rank=pc.Deck.RANKS['ace']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['five']), pc.Card(suit=pc.Deck.SUITS['diamonds'], rank=pc.Deck.RANKS['two']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['jack']) ] score, _ = s.check(hand) self.assertEqual(score, 5)
def _score_hand(self, cards): """Score a hand at the end of a round. :param cards: Cards in a single player's hand. :return: Points earned by player. """ score = 0 score_scenarios = [scoring.CountCombinationsEqualToN(n=15), scoring.HasPairTripleQuad(), scoring.HasStraight_InHand(), scoring.HasFlush()] for scenario in score_scenarios: s, desc = scenario.check(cards[:]) score += s print("[EOR SCORING] " + desc) if desc else None return score