示例#1
0
    def test_winner(self):
        standard_setup()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='c')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='w')

        id, points = check_winner(standard_boggle, 'cow')
        self.assertEqual(id, 0)
示例#2
0
    def test_reused_dice(self):
        standard_setup()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(1, 0), value='i')
        standard_boggle.set_board_value(position=(1, 1), value='n')
        standard_boggle.set_board_value(position=(2, 0), value='t')

        self.assertTrue(not standard_boggle._check_move(move='init',
                                                        board_id=0,
                                                        generous_boggle=False))
示例#3
0
    def test_generous_reused_dice(self):
        standard_setup()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='a')
        standard_boggle.set_board_value(position=(1, 0), value='l')
        standard_boggle.set_board_value(position=(2, 0), value='k')
        standard_boggle.set_board_value(position=(2, 1), value='y')

        self.assertTrue(standard_boggle._check_move(move='alkyl',
                                                    board_id=0,
                                                    generous_boggle=True))
示例#4
0
    def test_get_word_list(self):
        standard_setup()
        load_minimal_language()
        HostIO.set_terminal_output(True)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='w')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='r')
        standard_boggle.set_board_value(position=(0, 3), value='d')

        standard_boggle.game_paralell_process()
        self.assertCountEqual(standard_boggle.get_words_in_board(), ['word'])
示例#5
0
    def move_check(self, positions, output_text=""):
        standard_setup()
        standard_boggle = StandardBoggle(number_of_boards=1, board_size=4)

        standard_boggle.set_board_value(position=positions[0], value='c')
        standard_boggle.set_board_value(position=positions[1], value='o')
        standard_boggle.set_board_value(position=positions[2], value='w')

        # PlayerIO.set_mockup(True)
        # PlayerIO.write_player_gameboard(0, standard_boggle.get_board_string(board_id=0), "", 4)
        self.assertTrue(standard_boggle._check_move(move='cow',
                                                    board_id=0,
                                                    generous_boggle=False,
                                                    register_used_word=False),
                        msg=output_text)

        standard_boggle.set_board_value(position=positions[2], value='c')
        standard_boggle.set_board_value(position=positions[1], value='o')
        standard_boggle.set_board_value(position=positions[0], value='w')

        self.assertTrue(standard_boggle._check_move(move='cow',
                                                    board_id=0,
                                                    generous_boggle=False,
                                                    register_used_word=False),
                        msg=output_text)
示例#6
0
    def test_reused_word(self):
        standard_setup()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='c')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='w')

        standard_boggle._check_move(move='cow',
                                    board_id=0,
                                    generous_boggle=False)

        self.assertTrue(not standard_boggle._check_move(move='cow',
                                                        board_id=0,
                                                        generous_boggle=False))
示例#7
0
    def test_change_dict(self):
        load_compleat_language()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(1, 0), value='n')
        standard_boggle.set_board_value(position=(1, 1), value='o')
        standard_boggle.set_board_value(position=(1, 2), value='t')

        self.assertTrue(standard_boggle._check_move(move='not',
                                                    board_id=0,
                                                    generous_boggle=False))

        load_uncompleat_language()
        self.assertTrue(not standard_boggle._check_move(move='not',
                                                        board_id=0,
                                                        generous_boggle=False))
示例#8
0
    def test_winner_length(self):
        standard_setup()

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='i')
        standard_boggle.set_board_value(position=(0, 1), value='f')

        id, points = check_winner(standard_boggle, 'if')
        self.assertEqual(points, 0)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='c')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='w')

        id, points = check_winner(standard_boggle, 'cow')
        self.assertEqual(points, 1)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='c')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='w')
        standard_boggle.set_board_value(position=(0, 3), value='s')

        id, points = check_winner(standard_boggle, 'cows')
        self.assertEqual(points, 1)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='m')
        standard_boggle.set_board_value(position=(0, 1), value='a')
        standard_boggle.set_board_value(position=(0, 2), value='t')
        standard_boggle.set_board_value(position=(0, 3), value='c')
        standard_boggle.set_board_value(position=(1, 3), value='h')

        id, points = check_winner(standard_boggle, 'match')
        self.assertEqual(points, 2)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='w')
        standard_boggle.set_board_value(position=(0, 1), value='i')
        standard_boggle.set_board_value(position=(0, 2), value='n')
        standard_boggle.set_board_value(position=(0, 3), value='n')
        standard_boggle.set_board_value(position=(1, 3), value='e')
        standard_boggle.set_board_value(position=(1, 2), value='r')

        id, points = check_winner(standard_boggle, 'winner')
        self.assertEqual(points, 3)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='l')
        standard_boggle.set_board_value(position=(0, 1), value='e')
        standard_boggle.set_board_value(position=(0, 2), value='t')
        standard_boggle.set_board_value(position=(0, 3), value='t')
        standard_boggle.set_board_value(position=(1, 3), value='e')
        standard_boggle.set_board_value(position=(1, 2), value='r')
        standard_boggle.set_board_value(position=(1, 1), value='s')

        id, points = check_winner(standard_boggle, 'letters')
        self.assertEqual(points, 5)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='p')
        standard_boggle.set_board_value(position=(0, 1), value='o')
        standard_boggle.set_board_value(position=(0, 2), value='s')
        standard_boggle.set_board_value(position=(0, 3), value='s')
        standard_boggle.set_board_value(position=(1, 3), value='i')
        standard_boggle.set_board_value(position=(1, 2), value='b')
        standard_boggle.set_board_value(position=(1, 1), value='l')
        standard_boggle.set_board_value(position=(1, 0), value='e')

        id, points = check_winner(standard_boggle, 'possible')
        self.assertEqual(points, 11)

        standard_boggle = StandardBoggle(number_of_boards=2, board_size=4)
        standard_boggle.set_board_value(position=(0, 0), value='a')
        standard_boggle.set_board_value(position=(0, 1), value='c')
        standard_boggle.set_board_value(position=(0, 2), value='t')
        standard_boggle.set_board_value(position=(0, 3), value='i')
        standard_boggle.set_board_value(position=(1, 3), value='v')
        standard_boggle.set_board_value(position=(1, 2), value='i')
        standard_boggle.set_board_value(position=(1, 1), value='t')
        standard_boggle.set_board_value(position=(1, 0), value='i')
        standard_boggle.set_board_value(position=(2, 0), value='e')
        standard_boggle.set_board_value(position=(3, 0), value='s')

        id, points = check_winner(standard_boggle, 'activities')
        self.assertEqual(points, 11)