Esempio n. 1
0
def test_drop_lines_single():
    b = Board(10, 22)
    b.current_tetromino = Tetromino("O", SPAWN["O"], COLORS["O"])
    b.ghost_tetromino = b.get_ghost_tetromino()
    for i in range(10):
        b.board_tetrominos_squares.append(Square(Point(i, 0), colors.ASH))
    b.board_tetrominos_squares.append(Square(Point(0, 1), colors.ASH))
    b.board_tetrominos_squares.append(Square(Point(1, 1), colors.ASH))
    b.board_tetrominos_squares.append(Square(Point(2, 1), colors.ASH))

    b.update_matrices()
    filled_indices = b.get_filled_indices()
    b.clear_lines(filled_indices)
    b.drop_lines(filled_indices)
    b.update_matrices()

    ghost_squares = b.ghost_tetromino.squares

    assert ghost_squares[0].x == 4
    assert ghost_squares[0].x == 4
    assert ghost_squares[0].y == 0
    assert ghost_squares[1].x == 5
    assert ghost_squares[1].y == 0
    assert ghost_squares[2].x == 5
    assert ghost_squares[2].y == 1
    assert ghost_squares[3].x == 4
    assert ghost_squares[3].y == 1

    for i in range(3):
        assert b.board_tetrominos_matrix[i][0] == 1
    for i in range(3, 10):
        assert b.board_tetrominos_matrix[i][0] == 0