Beispiel #1
0
 def test_two_pairs(self):
     hand = hands.YatzyHand()
     hand[:] = [
         self.dice[1], self.dice[0], self.dice[0], self.dice[3],
         self.dice[3]
     ]
     self.assertEqual(self.scoresheet.score_two_pairs(hand), 10)
Beispiel #2
0
def main():
    hand = hands.YatzyHand()
    print(hand)
Beispiel #3
0
 def test_yatzy(self):
     hand = hands.YatzyHand()
     hand[:] = self._seed([2, 2, 2, 2, 2])
     self.assertEqual(self.scoresheet.score_yatzy(hand), 50)
Beispiel #4
0
 def test_four_of_a_kind(self):
     hand = hands.YatzyHand()
     hand[:] = self._seed([2, 2, 2, 2, 5])
     self.assertEqual(self.scoresheet.score_four_of_a_kind(hand), 8)
Beispiel #5
0
 def test_two_pairs_no_pairs(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[1:]
     self.assertEqual(self.scoresheet.score_two_pairs(hand), 0)
Beispiel #6
0
 def test_one_pair(self):
     hand = hands.YatzyHand()
     hand[:] = [self.dice[0], self.dice[0], self.dice[3]]
     self.assertEqual(self.scoresheet.score_one_pair(hand), 2)
Beispiel #7
0
 def test_one_pair_no_pairs(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[:5]
     self.assertEqual(self.scoresheet.score_one_pair(hand), 0)
Beispiel #8
0
 def test_fives(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[:5]
     self.assertEqual(self.scoresheet.score_fives(hand), 5)
Beispiel #9
0
 def test_sixes(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[1:]
     self.assertEqual(self.scoresheet.score_sixes(hand), 6)
Beispiel #10
0
 def test_chance(self):
     hand = hands.YatzyHand()
     hand[:] = self._seed([4, 3, 3, 2, 1])
     self.assertEqual(self.scoresheet.score_chance(hand), 13)
Beispiel #11
0
 def test_full_house(self):
     hand = hands.YatzyHand()
     hand[:] = self._seed([2, 2, 5, 5, 5])
     self.assertEqual(self.scoresheet.score_full_house(hand), 19)
Beispiel #12
0
 def test_large_straight(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[1:]
     self.assertEqual(self.scoresheet.score_large_straight(hand), 20)
Beispiel #13
0
 def test_small_straight(self):
     hand = hands.YatzyHand()
     hand[:] = self.dice[:5]
     self.assertEqual(self.scoresheet.score_small_straight(hand), 15)
Beispiel #14
0
    def score_fours(self, hand):
        return sum(hand.fours)

    def score_fives(self, hand):
        return sum(hand.fives)

    def score_sixes(self, hand):
        return sum(hand.sixes)

    def _score_set(self, hand, set_size):
        scores = [0]
        for worth, count in hand._sets.items():
            if count == set_size:
                scores.append(worth * set_size)
        return max(scores)

    def score_one_pair(self, hand):
        return self._score_set(hand, 2)

    def score_chance(self, hand):
        scores = []
        for worth, count in hand._sets.items():
            scores.append(worth * count)
        return sum(scores)


yss = YatzyScoresheet()
yh = hands.YatzyHand()
print(yh)
print(yss.score_chance(yh))