class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.g = GameBoard(4, False)

    def test_winner_new_stich(self):
        self.g.new_round()
        s = Stich(self.g.player_queue, ColoredCard(0, "yellow"))
        s.winner = self.g.players[3]
        self.g.get_current_round().stiche.append(s)

        self.assertEqual(self.g.set_stich_queue(2)[0], self.g.players[3])

    def test_stich_round_3(self):
        self.g.current_round_count = 3
        r = [Round(1), Round(2), Round(3)]
        s = [Stich(self.g.player_queue), Stich(self.g.player_queue)]

        s[1].winner = self.g.players[2]
        r[2].stiche.extend(s)
        self.g.score_board.round_score.extend(r)
        result = tuple(self.g.set_stich_queue(3))
        expected = tuple([
            self.g.players[2], self.g.players[3], self.g.players[0],
            self.g.players[1]
        ])
        self.assertTupleEqual(result, expected)
Exemple #2
0
class TestStichWinnerAtutNone(TestCase):
    def setUp(self) -> None:
        self.g = GameBoard(4, False)
        self.g.new_round()
        # noinspection PyTypeChecker
        self.s = Stich(self.g.player_queue, None)

    def test_single_atutwin(self):
        self.s.cards_in_play.append(ColoredCard(5, 'green'))
        self.s.cards_in_play.append(ColoredCard(6, 'green'))
        self.s.cards_in_play.append(ColoredCard(10, 'green'))
        self.s.cards_in_play.append(ColoredCard(5, 'red'))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[2])

    def test_colorwin(self):
        self.s.cards_in_play.append(ColoredCard(5, 'green'))
        self.s.cards_in_play.append(ColoredCard(6, 'green'))
        self.s.cards_in_play.append(ColoredCard(10, 'green'))
        self.s.cards_in_play.append(ColoredCard(13, 'green'))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[3])

    def test_wizzard_win(self):
        self.s.cards_in_play.append(SpecialCard("z"))
        self.s.cards_in_play.append(ColoredCard(6, 'green'))
        self.s.cards_in_play.append(ColoredCard(10, 'green'))
        self.s.cards_in_play.append(ColoredCard(13, 'green'))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[0])

    def test_narr_only_win(self):
        self.s.cards_in_play.append(SpecialCard("n"))
        self.s.cards_in_play.append(SpecialCard("n"))
        self.s.cards_in_play.append(SpecialCard("n"))
        self.s.cards_in_play.append(SpecialCard("n"))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[0])

    def test_multiple_atut_win(self):
        self.s.cards_in_play.append(ColoredCard(6, 'red'))
        self.s.cards_in_play.append(ColoredCard(10, 'red'))
        self.s.cards_in_play.append(ColoredCard(13, 'red'))
        self.s.cards_in_play.append(SpecialCard('n'))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[2])

    def test_dominant_color_win(self):
        self.s.cards_in_play.append(ColoredCard(12, 'green'))
        self.s.cards_in_play.append(ColoredCard(10, 'green'))
        self.s.cards_in_play.append(ColoredCard(13, 'yellow'))
        self.s.cards_in_play.append(ColoredCard(9, 'blue'))

        self.assertEqual(self.s.check_stich_winner(), self.s.player_q[0])