using System;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using ProtoBuf;

namespace ET
{
    [ProtoContract]
    [Config]
    public partial class MapConfigCategory : ConfigSingleton<MapConfigCategory>, IMerge
    {
        [ProtoIgnore]
        [BsonIgnore]
        private Dictionary<int, MapConfig> dict = new Dictionary<int, MapConfig>();
		
        [BsonElement]
        [ProtoMember(1)]
        private List<MapConfig> list = new List<MapConfig>();
		
        public void Merge(object o)
        {
            MapConfigCategory s = o as MapConfigCategory;
            this.list.AddRange(s.list);
        }
		
		[ProtoAfterDeserialization]        
        public void ProtoEndInit()
        {
            foreach (MapConfig config in list)
            {
                config.AfterEndInit();
                this.dict.Add(config.Id, config);
            }
            this.list.Clear();
            
            this.AfterEndInit();
        }
		
        public MapConfig Get(int id)
        {
            this.dict.TryGetValue(id, out MapConfig item);

            if (item == null)
            {
                throw new Exception($"配置找不到,配置表名: {nameof (MapConfig)},配置id: {id}");
            }

            return item;
        }
		
        public bool Contain(int id)
        {
            return this.dict.ContainsKey(id);
        }

        public Dictionary<int, MapConfig> GetAll()
        {
            return this.dict;
        }

        public MapConfig GetOne()
        {
            if (this.dict == null || this.dict.Count <= 0)
            {
                return null;
            }
            return this.dict.Values.GetEnumerator().Current;
        }
    }

    [ProtoContract]
	public partial class MapConfig: ProtoObject, IConfig
	{
		/// <summary>Id</summary>
		[ProtoMember(1)]
		public int Id { get; set; }
		/// <summary>名字</summary>
		[ProtoMember(2)]
		public string Name { get; set; }
		/// <summary>成色</summary>
		[ProtoMember(3)]
		public int Qcolor { get; set; }
		/// <summary>玩法类型</summary>
		[ProtoMember(4)]
		public int Type { get; set; }
		/// <summary>场景类型</summary>
		[ProtoMember(5)]
		public int AreaType { get; set; }
		/// <summary>地图模版id</summary>
		[ProtoMember(6)]
		public int TemplateID { get; set; }
		/// <summary>怪物强度</summary>
		[ProtoMember(7)]
		public string MonsterHard { get; set; }
		/// <summary>所属阵营</summary>
		[ProtoMember(8)]
		public int Race { get; set; }
		/// <summary>默认PK模式</summary>
		[ProtoMember(9)]
		public int Pktype { get; set; }
		/// <summary>是否允许改变PK模式</summary>
		[ProtoMember(10)]
		public int changePKtype { get; set; }
		/// <summary>是否无视PK红名规则</summary>
		[ProtoMember(11)]
		public int ignorePkRule { get; set; }
		/// <summary>是否可使用回城功能</summary>
		[ProtoMember(12)]
		public int canBeTrans { get; set; }
		/// <summary>地图等级</summary>
		[ProtoMember(13)]
		public int MapLevel { get; set; }
		/// <summary>掉线后返回地图ID</summary>
		[ProtoMember(14)]
		public int DisConnToMapID { get; set; }
		/// <summary>复活地图ID</summary>
		[ProtoMember(15)]
		public int RevivedMapID { get; set; }
		/// <summary>生命周期</summary>
		[ProtoMember(16)]
		public int LifeTime { get; set; }
		/// <summary>人数软上限</summary>
		[ProtoMember(17)]
		public int FullPlayers { get; set; }
		/// <summary>人数硬上限</summary>
		[ProtoMember(18)]
		public int MaxPlayers { get; set; }
		/// <summary>状态分界值</summary>
		[ProtoMember(19)]
		public int Boundary { get; set; }
		/// <summary>需要等级</summary>
		[ProtoMember(20)]
		public int ReqLevel { get; set; }
		/// <summary>限制等级</summary>
		[ProtoMember(21)]
		public int Levellimit { get; set; }
		/// <summary>需要VIP等级</summary>
		[ProtoMember(22)]
		public string ReqVip { get; set; }
		/// <summary>需要任务ID</summary>
		[ProtoMember(23)]
		public int ReqQuestId { get; set; }
		/// <summary>可进入阵营</summary>
		[ProtoMember(24)]
		public int AllowedRace { get; set; }
		/// <summary>状态条件</summary>
		[ProtoMember(25)]
		public string ReqState { get; set; }
		/// <summary>状态值</summary>
		[ProtoMember(26)]
		public int StateValue { get; set; }
		/// <summary>开放策略</summary>
		[ProtoMember(27)]
		public int OpenRule { get; set; }
		/// <summary>开放日</summary>
		[ProtoMember(28)]
		public string OpenDate { get; set; }
		/// <summary>开始时间</summary>
		[ProtoMember(29)]
		public string BeginTime { get; set; }
		/// <summary>结束时间</summary>
		[ProtoMember(30)]
		public string EndTime { get; set; }
		/// <summary>关闭时强制传送到地图ID</summary>
		[ProtoMember(31)]
		public int ClosedToMapID { get; set; }
		/// <summary>进入是否扣除队员物品</summary>
		[ProtoMember(32)]
		public int ReqNotOnlyLeader { get; set; }
		/// <summary>进入需要物品Code</summary>
		[ProtoMember(33)]
		public string ReqItemCode { get; set; }
		/// <summary>进入需要物品数量</summary>
		[ProtoMember(34)]
		public int ReqItemCount { get; set; }
		/// <summary>进入后扣除物品数量</summary>
		[ProtoMember(35)]
		public int ReduceItemCount { get; set; }
		/// <summary>是否可以传送</summary>
		[ProtoMember(36)]
		public int AllowedTransfer { get; set; }
		/// <summary>传送消耗道具</summary>
		[ProtoMember(37)]
		public string CostItem { get; set; }
		/// <summary>传送消耗道具数量</summary>
		[ProtoMember(38)]
		public int CostItemNum { get; set; }
		/// <summary>扣除金币</summary>
		[ProtoMember(39)]
		public int CostGold { get; set; }
		/// <summary>随机宝箱出现概率</summary>
		[ProtoMember(40)]
		public int RandChestChance { get; set; }
		/// <summary>随机宝箱最大数量</summary>
		[ProtoMember(41)]
		public int MaxRandChest { get; set; }
		/// <summary>随机宝箱TC</summary>
		[ProtoMember(42)]
		public string RandChestTC { get; set; }
		/// <summary>场景小地图</summary>
		[ProtoMember(43)]
		public string MapName { get; set; }
		/// <summary>地图描述</summary>
		[ProtoMember(45)]
		public string MapDesc { get; set; }
		/// <summary>场景传送</summary>
		[ProtoMember(46)]
		public string Connect { get; set; }
		/// <summary>是否允许改变分配方式</summary>
		[ProtoMember(47)]
		public int IsChange { get; set; }
		/// <summary>默认分配模式</summary>
		[ProtoMember(48)]
		public int Distribution { get; set; }
		/// <summary>能否自动战斗</summary>
		[ProtoMember(49)]
		public int AutoFight { get; set; }
		/// <summary>能否吃药剂</summary>
		[ProtoMember(50)]
		public int UseAgent { get; set; }
		/// <summary>能否使用坐骑</summary>
		[ProtoMember(51)]
		public int RideMount { get; set; }
		/// <summary>能否携带宠物</summary>
		[ProtoMember(52)]
		public int TakePet { get; set; }
		/// <summary>是否重置状态</summary>
		[ProtoMember(53)]
		public int Recovery { get; set; }
		/// <summary>BOSS列表显示</summary>
		[ProtoMember(54)]
		public int BossInfoShow { get; set; }
		/// <summary>连杀时间间隔-毫秒</summary>
		[ProtoMember(55)]
		public int killInterval { get; set; }
		/// <summary>连杀满值重置</summary>
		[ProtoMember(56)]
		public int killFullNum { get; set; }
		/// <summary>连杀满值冷却-秒</summary>
		[ProtoMember(57)]
		public int killFullCollSec { get; set; }
		/// <summary>灵气点采集修为值</summary>
		[ProtoMember(58)]
		public int Cultivation { get; set; }
		/// <summary>地图是否有迷雾</summary>
		[ProtoMember(59)]
		public int IsFog { get; set; }
		/// <summary>副本通关时长</summary>
		[ProtoMember(60)]
		public int GameTime { get; set; }
		/// <summary>能否进行召唤</summary>
		[ProtoMember(61)]
		public int IsCall { get; set; }
		/// <summary>能否响应召唤</summary>
		[ProtoMember(62)]
		public int IsCanBeCall { get; set; }

	}
}