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)))
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)))
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)
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)
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)
def _generate_usual() -> Ball: return Ball([BallColor(random.randint(0, 6))])
def _generate_multicolor() -> Ball: colors = [BallColor(random.randint(0, 6)) for _ in range(2)] return Ball(colors)
def setUp(self): self.ball_cell = Cell(Ball({BallColor.RED})) # type: Cell self.cell = Cell() # type: Cell
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))
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)
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)))
def setUp(self): self.one_color_ball = Ball({BallColor.CYAN}) # type: Ball self.multicolor_color_ball = Ball({BallColor.CYAN, BallColor.BROWN}) # type: Ball