using System;
using ProtoBuf;
using Fantasy;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Collections.Concurrent;
using Fantasy.Serialize;
using Fantasy.ConfigTable;

namespace NBF
{
    [ProtoContract]
    public sealed partial class FishConfig : ASerialize, IProto, IConfigTable
    {
    
		[ProtoMember(1)]
		public uint Id { get; set; } // Id
		[ProtoMember(2)]
		public string[] Model { get; set; } = Array.Empty<string>(); // 模型
		[ProtoMember(3)]
		public uint Type { get; set; } // 类型
		[ProtoMember(4)]
		public uint SpeciesName { get; set; } // 鱼类型Id
		[ProtoMember(5)]
		public uint MinWeight { get; set; } // 最小重量(克)
		[ProtoMember(6)]
		public uint MaxWeight { get; set; } // 最大重量(克)
		[ProtoMember(7)]
		public uint Accept { get; set; } // 接受饵  
        [ProtoIgnore]
        public uint Key => Id;
        
        #region Static
        
        private static ConfigContext<FishConfig> Context => ConfigTableHelper.Table<FishConfig>();

        public static FishConfig Get(uint key)
        {
            return Context.Get(key);
        }

        public static FishConfig Get(Predicate<FishConfig> match)
        {
            return Context.Get(match);
        }
        
        public static FishConfig Fist()
        {
            return Context.Fist();
        }

        public static FishConfig Last()
        {
            return Context.Last();
        }

        public static FishConfig Fist(Predicate<FishConfig> match)
        {
            return Context.Fist(match);
        }

        public static FishConfig Last(Predicate<FishConfig> match)
        {
            return Context.Last(match);
        }
        
        public static int Count()
        {
            return Context.Count();
        }

        public static int Count(Func<FishConfig, bool> predicate)
        {
            return Context.Count(predicate);
        }

        public static List<FishConfig> GetList()
        {
            return Context.GetList();
        }

        public static List<FishConfig> GetList(Predicate<FishConfig> match)
        {
            return Context.GetList(match);
        }
        public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
        {
            ConfigTableHelper.ParseLine<FishConfig>(arr);
        }
        #endregion
    }
}