Esempio n. 1
0
    def test_is_path_exists(self):
        for i in self.field.width_r:
            self.field[(i, 2)] = Cell(Ball({BallColor.BROWN}))
        self.field[(0, 0)] = Cell(Ball({BallColor.RED}))

        self.assertTrue(self.field.is_path_exists((0, 0), (0, 1)))
        self.assertFalse(self.field.is_path_exists((0, 0), (3, 3)))
Esempio n. 2
0
    def test_is_correct_move(self):
        for i in self.field.width_r:
            self.field[(i, 2)] = Cell(Ball({BallColor.BROWN}))
        self.field[(0, 0)] = Cell(Ball({BallColor.RED}))
        self.field[(1, 2)] = Cell(Ball({BallColor.BLUE}))

        self.assertFalse(self.field.is_correct_move((0, 2), (0, 2)))
        self.assertFalse(self.field.is_correct_move((0, 0), (3, 3)))
Esempio n. 3
0
 def setUp(self):
     field = GameField(5)
     for i in field.width_r:
         field[(i, 0)] = Cell(Ball({BallColor.BROWN}))
     self.controller = Controller(field,
                                  ScoreBoard("", {"1": 100}, 1),
                                  False)
Esempio n. 4
0
    def test_perform_move(self):
        ball = Ball({BallColor.RED})
        self.field[(0, 0)] = Cell(ball)

        self.field.perform_move((0, 0), (3, 3))

        self.assertTrue(self.field[(3, 3)].ball == ball)
Esempio n. 5
0
    def test_try_remove_lines(self):
        for i in self.field.width_r:
            self.field[(i, 0)] = Cell(Ball({BallColor.BROWN}))

        self.field.try_remove_lines(self.field.get_completed_lines((0, 0)))

        count = self.field.empty_cells_count
        self.assertTrue(count == 25)
Esempio n. 6
0
 def _generate_usual() -> Ball:
     return Ball([BallColor(random.randint(0, 6))])
Esempio n. 7
0
 def _generate_multicolor() -> Ball:
     colors = [BallColor(random.randint(0, 6)) for _ in range(2)]
     return Ball(colors)
Esempio n. 8
0
 def setUp(self):
     self.ball_cell = Cell(Ball({BallColor.RED}))  # type: Cell
     self.cell = Cell()  # type: Cell
Esempio n. 9
0
    def test_find_move_for_hint(self):
        self.controller.field[(1, 1)].ball = Ball({BallColor.BROWN})
        self.controller.field[(3, 3)].ball = Ball({BallColor.BROWN})

        self.assertTrue(self.controller.find_move_for_hint()[1] == (2, 2))
Esempio n. 10
0
    def test_find_lines(self):
        for i in self.field.width_r:
            self.field[(i, 0)] = Cell(Ball({BallColor.BROWN}))

        self.assertTrue(len(self.field.find_lines((0, 0))) == 4)
Esempio n. 11
0
    def test_get_completed_lines(self):
        for i in self.field.width_r:
            self.field[(i, 0)] = Cell(Ball({BallColor.BROWN}))

        self.assertTrue(self.field.get_completed_lines((0, 0)))
Esempio n. 12
0
 def setUp(self):
     self.one_color_ball = Ball({BallColor.CYAN})  # type: Ball
     self.multicolor_color_ball = Ball({BallColor.CYAN,
                                        BallColor.BROWN})  # type: Ball