using System.Collections.Generic;
using System.Linq;

namespace ZionExtractor.Controllers.LegworkMethods
{
    class BestQuality
    {
        public static List<ZionExtractor.Models.Hypothesis> Search(List<ZionVault.Binder.Output.Field> fields)
        {
            try
            {
                List<ZionExtractor.Models.Hypothesis> list = new List<ZionExtractor.Models.Hypothesis>();
                ZionVault.Binder.Output.Field Chosen = (from ZionVault.Binder.Output.Field field in fields
                                                        orderby field.Quality descending
                                                        select field).First();

                list.Add(new ZionExtractor.Models.Hypothesis(
                        Chosen.Value,
                        Chosen.Position,
                        Chosen.Quality));

                return list;
            }
            catch
            {
                return new List<ZionExtractor.Models.Hypothesis>();
            }
        }
    }
}
