def _score_play(self, card_seq): """Return score for latest move in an active play sequence. :param card_seq: List of all cards played (oldest to newest). :return: Points earned by player of latest card played in the sequence. """ score = 0 score_scenarios = [scoring.ExactlyEqualsN(n=15), scoring.ExactlyEqualsN(n=31), scoring.HasPairTripleQuad(), scoring.HasStraight_DuringPlay()] for scenario in score_scenarios: s, desc = scenario.check(card_seq[:]) score += s print("[SCORE] " + desc) if desc else None return score
def test_ExactlyEqualsN15_one_card(self): s = scoring.ExactlyEqualsN(n=15) hand = [ pc.Card(suit=pc.Deck.SUITS['spades'], rank=pc.Deck.RANKS['ace']) ] score, _ = s.check(hand) self.assertEqual(score, 0)
def test_ExactlyEqualsN15_count_is_less_than(self): s = scoring.ExactlyEqualsN(n=15) hand = [ pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['nine']), pc.Card(suit=pc.Deck.SUITS['diamonds'], rank=pc.Deck.RANKS['five']) ] score, _ = s.check(hand) self.assertEqual(score, 0)
def test_ExactlyEqualsN31_count_is_less_than(self): s = scoring.ExactlyEqualsN(n=31) 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['jack']), pc.Card(suit=pc.Deck.SUITS['hearts'], rank=pc.Deck.RANKS['queen']) ] score, _ = s.check(hand) self.assertEqual(score, 0)