Example #1
0
        public static DailyVipGoodsRecord GetToday(long QQNum)
        {
            var record = MongoService <DailyVipGoodsRecord> .GetOnly(p => p.QQNum == QQNum);

            if (record == null)
            {
                record = new DailyVipGoodsRecord()
                {
                    QQNum = QQNum
                };
                MongoService <DailyVipGoodsRecord> .Insert(record);
            }

            var dateStr = DateTime.Now.ToString("yyyy-MM-dd");

            if (record.Date == dateStr)
            {
                return(record);
            }

            record.Date      = dateStr;
            record.GoodsName = AutofacSvc.Resolve <DailyVipShopSvc>().RandGoods(7);
            record.Update();

            return(record);
        }
Example #2
0
        public static string ItemIncome(this ItemCollectionRecord record, string itemName, int count = 1)
        {
            var isNew       = false;
            var HonorHelper = AutofacSvc.Resolve <HonorSvc>();
            var honorName   = HonorHelper.FindHonorName(itemName);
            var honor       = HonorHelper.FindHonor(honorName);

            if (!record.HonorCollections.ContainsKey(honorName))
            {
                record.HonorCollections.Add(honorName, new HonorItemCollection()
                {
                    Name = honorName,
                    Type = honor is LimitHonorModel ? HonorType.Limit : HonorType.Normal
                });
                isNew = true;
            }

            var collection = record.HonorCollections[honorName];

            if (!collection.Items.ContainsKey(itemName))
            {
                collection.Items.Add(itemName, 0);
                isNew = true;
            }

            collection.Items[itemName] += count;
            record.Update();

            if (!isNew || collection.Items.Count < honor.Items.Count)
            {
                return($"成就 【{honor.FullName}】 完成度:{collection.Items.Count}/{honor.Items.Count}");
            }

            return($"恭喜你解锁了成就 【{honor.FullName}】! (集齐物品:{string.Join(",", honor.Items.Select(p => p.Name))})");
        }
Example #3
0
        /// <summary>
        /// 获取权限等级
        /// </summary>
        /// <param name="MsgDTO"></param>
        /// <returns></returns>
        public static AuthorityLevel GetAuth(MsgInformationEx MsgDTO)
        {
            if (MsgDTO.FromQQ == Global.DeveloperNumber)
            {
                return(AuthorityLevel.开发者);
            }

            if (MsgDTO.Type == MsgType.Private)
            {
                return(AuthorityLevel.成员);
            }

            var setting = AutofacSvc.Resolve <GroupSettingSvc>()[MsgDTO.FromGroup];

            if (setting.AuthInfo == null)
            {
                return(AuthorityLevel.成员);
            }

            if (setting.AuthInfo.Owner == MsgDTO.FromQQ)
            {
                return(AuthorityLevel.群主);
            }

            return(setting.AuthInfo.Mgrs.Contains(MsgDTO.FromQQ) ? AuthorityLevel.管理员 : AuthorityLevel.成员);
        }
Example #4
0
        public int AssertToGold()
        {
            var itemAssert  = 0;
            var HonorHelper = AutofacSvc.Resolve <HonorSvc>();

            foreach (var(honorName, collection) in HonorCollections)
            {
                var honorModel = HonorHelper.FindHonor(honorName);
                var honorPrice = honorModel.Items.Sum(p => p.Price) * 3 / 2;
                while (collection.Items != null && honorModel.Items.Count == collection.Items.Count)
                {
                    itemAssert += honorPrice;

                    for (var i = 0; i < collection.Items.Count; i++)
                    {
                        collection.Items[collection.Items.Keys.ElementAt(i)]--;
                    }

                    collection.Items.Remove(p => p == 0);
                }

                itemAssert += collection.Items?.Sum(p => honorModel.Items.First(item => item.Name == p.Key).Price *p.Value) ?? 0;
            }

            return(itemAssert);
        }
Example #5
0
        static void Main(string[] args)
        {
            var assemblies = new List <Assembly>()
            {
                Assembly.GetAssembly(typeof(IDependency)),      // Dolany.Ai.Common
                Assembly.GetAssembly(typeof(Program)),          // DoremiDesktop
                Assembly.GetAssembly(typeof(IWorldLine)),       // Dolany.Ai.Core
                Assembly.GetAssembly(typeof(DbBaseEntity)),     // Dolany.Database
                Assembly.GetAssembly(typeof(DoremiWorldLine)),  // Dolany.Ai.Doremi
                Assembly.GetAssembly(typeof(StandardWorldLine)) // Dolany.WorldLine.Standard
            };

            AutofacSvc.RegisterAutofac(assemblies);

            var pcCpuLoad = new PerformanceCounter("Processor", "% Processor Time", "_Total")
            {
                MachineName = "."
            };

            while (true)
            {
                var load = pcCpuLoad.NextValue();
                Console.WriteLine(load);
                Thread.Sleep(1000);
            }

            Console.WriteLine("Completed");
            Console.ReadKey();
        }
Example #6
0
        static void Main()
        {
            var assemblies = new List <Assembly>()
            {
                Assembly.GetAssembly(typeof(IDependency)),          // Dolany.Ai.Common
                Assembly.GetAssembly(typeof(Program)),              // DolanyTimingSvc
                Assembly.GetAssembly(typeof(DbBaseEntity)),         // Dolany.Database
                Assembly.GetAssembly(typeof(IWorldLine)),           // Dolany.Ai.Core
                Assembly.GetAssembly(typeof(StandardWorldLine)),    // Dolany.WorldLine.Standard
                Assembly.GetAssembly(typeof(KindomStormWorldLine)), // Dolany.WorldLine.KindomStorm
                Assembly.GetAssembly(typeof(DoremiWorldLine))       // Dolany.WorldLine.Doremi
            };

            try
            {
                AutofacSvc.RegisterAutofac(assemblies);
                AutofacSvc.RegisterDataRefresher(assemblies);

                Global.MsgPublish = PrintMsg;

                TimingSvcMgr.Init(assemblies);
                TimingSvcMgr.Load();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetFullDetailMsg());
            }

            var command = Console.ReadLine();

            while (command != "Exit")
            {
                command = Console.ReadLine();
            }
        }
Example #7
0
        public void InitWorlds(IEnumerable <Assembly> assemblies)
        {
            AllWorlds = AutofacSvc.LoadAllInstanceFromClass <IWorldLine>(assemblies).ToArray();

            foreach (var worldLine in AllWorlds)
            {
                worldLine.Init();
                worldLine.AIGroup.AddRange(CrossWorldAis);
                worldLine.Load();
            }
        }
Example #8
0
        public override string ToString()
        {
            var LotteryMgr = AutofacSvc.Resolve <LotterySvc>();
            var ordered    = LotteryDic.Select(p => new { Model = LotteryMgr[p.Key], Count = p.Value }).OrderByDescending(p => p.Model.Bonus).ToList();
            var str        = string.Join("\r\n", ordered.Select(p => $"{p.Model.Name}({p.Model.Bonus.CurencyFormat()})*{p.Count}次"));

            str += $"\r\n总计{ordered.Sum(p => p.Count)}次";
            str += $"\r\n总盈亏{ordered.Sum(p => (p.Model.Bonus - LotterySvc.LotteryFee) * p.Count).CurencyFormat()}";

            return(str);
        }
        private static DailySellItemModel[] CreateDailySellItems_Rare()
        {
            var honors   = AutofacSvc.Resolve <HonorSvc>().HonorList.Where(h => !h.IsLimit);
            var items    = honors.SelectMany(h => h.Items).Where(p => p.Price >= 500).ToArray();
            var randSort = Rander.RandSort(items).Take(5);

            return(randSort.Select(rs => new DailySellItemModel
            {
                Name = rs.Name,
                Price = rs.Price * 2,
                Attr = string.Join(",", rs.Attributes)
            }).ToArray());
        }
Example #10
0
        public void EscapeArmerGet(string name, int count = 1)
        {
            if (EscapeArmers == null)
            {
                EscapeArmers = new Dictionary <string, int>();
            }

            if (!EscapeArmers.ContainsKey(name))
            {
                EscapeArmers.Add(name, 0);
            }

            var model = AutofacSvc.Resolve <EscapeArmerSvc>()[name];

            EscapeArmers[name] = Math.Min(model.MaxContains, EscapeArmers[name] + count);
        }
Example #11
0
        public void Init()
        {
            AllAis = CommonUtil.ReadJsonData_NamedList <BindAiModel>("BindAiData");

            foreach (var ai in AllAis)
            {
                ClientsDic.TryAdd(ai.Name, new WSClient($"ws://localhost:{ai.BindPort}/{ai.Name}/", ai.Name, MessageInvoke));
            }

            SchedulerSvc.Add(SchedulerTimer.SecondlyInterval * Global.Config.ReconnectSecords, Reconnect);

            CommandResolvers = AutofacSvc.LoadAllInstanceFromInterface <ICmdResovler>();
            MessageResolvers = AutofacSvc.LoadAllInstanceFromInterface <IMsgResolver>();

            Global.MQSvc.StartReceive <MsgCommand>(CommandInvoke);
        }
Example #12
0
        public static string ExtGain(this PetRecord pet, MsgInformationEx MsgDTO, int exp)
        {
            var remainExp   = pet.Exp + exp;
            var lvl         = pet.Level;
            var PetLevelMgr = AutofacSvc.Resolve <PetLevelSvc>();
            var levelMode   = PetLevelMgr[lvl];

            while (levelMode.Exp <= remainExp)
            {
                remainExp -= levelMode.Exp;
                lvl++;
                levelMode = PetLevelMgr[lvl];
            }

            var msg = $"{pet.Name}获得了 {exp} 点经验值!";

            if (lvl > pet.Level)
            {
                var points = (lvl - pet.Level) * 2;
                msg += $"\r\n恭喜{pet.Name}升到了 {lvl} 级!\r\n" +
                       $"{pet.Name}获得了 {points} 点技能点!";

                pet.RemainSkillPoints += points;

                var skills = AutofacSvc.Resolve <PetSkillSvc>().AllSkills.Where(p => p.LearnLevel > pet.Level && p.LearnLevel <= lvl).ToList();

                if (!skills.IsNullOrEmpty())
                {
                    msg += $"\r\n恭喜{pet.Name}学会了新技能 {string.Join(",", skills.Select(p => p.Name))}!";
                    if (pet.Skills == null)
                    {
                        pet.Skills = new Dictionary <string, int>();
                    }
                    foreach (var skill in skills)
                    {
                        pet.Skills.Add(skill.Name, 1);
                    }
                }
            }

            pet.Level = lvl;
            pet.Exp   = remainExp;
            pet.Update();

            return(msg);
        }
Example #13
0
        public static KindomCastle Get(long GroupNum, long QQNum)
        {
            var castle = MongoService <KindomCastle> .GetOnly(p => p.QQNum == QQNum);

            if (castle != null)
            {
                return(castle);
            }

            var group = AutofacSvc.Resolve <GroupSettingSvc>()[GroupNum];
            var info  = APIEx.GetQQInfo(QQNum, group.BindAi);

            castle = new KindomCastle()
            {
                QQNum = QQNum, CharactorName = info.nick, CastleName = $"{info.nick}的城堡", Buildings = CastleBuildingSvc.Buildings.ToDictionary(p => p.Name, p => 1)
            };
            MongoService <KindomCastle> .Insert(castle);

            return(castle);
        }
Example #14
0
        public static ArchDailyScene Get(long QQNum)
        {
            var todayStr = DateTime.Today.ToString("yyyyMMdd");
            var rec      = MongoService <ArchDailyScene> .GetOnly(p => p.QQNum == QQNum && p.DateStr == todayStr);

            if (rec != null)
            {
                return(rec);
            }

            var svc = AutofacSvc.Resolve <ArchaeologySceneSvc>();

            rec = new ArchDailyScene()
            {
                QQNum = QQNum, DateStr = todayStr, Scenes = svc.RandScenes(5).Select(p => p.Name).ToList()
            };
            MongoService <ArchDailyScene> .Insert(rec);

            return(rec);
        }
Example #15
0
        static void Main()
        {
            var assemblies = new List <Assembly>()
            {
                Assembly.GetAssembly(typeof(IDependency)),         // Dolany.Ai.Common
                Assembly.GetAssembly(typeof(Program)),             // DoremiDesktop
                Assembly.GetAssembly(typeof(IWorldLine)),          // Dolany.Ai.Core
                Assembly.GetAssembly(typeof(DbBaseEntity)),        // Dolany.Database
                Assembly.GetAssembly(typeof(DoremiWorldLine)),     // Dolany.Ai.Doremi
                Assembly.GetAssembly(typeof(StandardWorldLine)),   // Dolany.WorldLine.Standard
                Assembly.GetAssembly(typeof(KindomStormWorldLine)) // Dolany.WorldLine.KindomStorm
            };

            try
            {
                AutofacSvc.RegisterAutofac(assemblies);
                AutofacSvc.RegisterDataRefresher(assemblies);

                Global.MsgPublish = PrintMsg;
                SFixedSetService.SetMaxCount("PicCache_Doremi", 200);
                AIAnalyzer.Sys_StartTime = DateTime.Now;

                CrossWorldAiSvc.InitWorlds(assemblies);
                CrossWorldAiSvc.DefaultWorldLine = CrossWorldAiSvc["Doremi"];

                WaiterSvc.Listen();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetFullDetailMsg());
            }

            var command = Console.ReadLine();

            while (command != "Exit")
            {
                command = Console.ReadLine();
            }
        }
Example #16
0
        public static bool RefreshGroupInfo(long GroupNum, string BindAi)
        {
            var infos = APIEx.GetMemberInfos(GroupNum, BindAi);

            if (infos?.members == null)
            {
                Logger.Log($"Cannot get Group Member Infos:{GroupNum}");
                return(false);
            }

            var GroupSettingMgr = AutofacSvc.Resolve <GroupSettingSvc>();
            var setting         = GroupSettingMgr[GroupNum];

            setting.AuthInfo = new GroupAuthInfoModel {
                Owner = infos.owner, Mgrs = infos.adm?.ToList() ?? new List <long>()
            };
            setting.MembersCount = infos.members.Count;

            setting.Update();
            Logger.Log($"Refresh Group Info: {GroupNum} completed");

            return(true);
        }
Example #17
0
        protected override void ScheduleDo(SchedulerTimer timer)
        {
            var curHour  = DateTime.Now.Hour;
            var settings = MongoService <AutoPowerSetting> .Get(p => p.Hour == curHour);

            foreach (var setting in settings)
            {
                var GroupSettingMgr = AutofacSvc.Resolve <GroupSettingSvc>();
                switch (setting.ActionType)
                {
                case AutoPowerSettingActionType.PowerOn:
                {
                    var groupSetting = GroupSettingMgr[setting.GroupNum];
                    groupSetting.IsPowerOn = true;
                    groupSetting.Update();

                    MsgSender.PushMsg(setting.GroupNum, 0, "开机成功!", groupSetting.BindAi);
                    break;
                }

                case AutoPowerSettingActionType.PowerOff:
                {
                    var groupSetting = GroupSettingMgr[setting.GroupNum];
                    groupSetting.IsPowerOn = false;
                    groupSetting.Update();

                    MsgSender.PushMsg(setting.GroupNum, 0, "关机成功!", groupSetting.BindAi);
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            timer.Interval = SchedulerTimer.NextHourInterval;
        }
Example #18
0
        protected override void ScheduleDo(SchedulerTimer timer)
        {
            AutofacSvc.Resolve <HonorSvc>().RefreshData();

            timer.Interval = (DateTime.Now.Date.AddDays(1) - DateTime.Now).TotalMilliseconds;
        }
Example #19
0
 public SyntaxCheckerSvc()
 {
     Checkers = AutofacSvc.LoadAllInstanceFromInterface <ISyntaxChecker>();
 }
Example #20
0
 public DailyVipShopSvc()
 {
     Armers = AutofacSvc.LoadAllInstanceFromInterface <IVipArmer>();
 }
Example #21
0
 public ArchAdvSubSceneSvc()
 {
     SubScenes = AutofacSvc.LoadAllInstanceFromInterface <IArchAdvSubScene>();
 }
Example #22
0
        public void Init()
        {
            var assembly = GetType().Assembly;

            AIGroup = AutofacSvc.LoadAllInstanceFromClass <AIBase>(assembly);
        }
Example #23
0
 public void Init(IEnumerable <Assembly> assemblies)
 {
     ToolGroup = AutofacSvc.LoadAllInstanceFromInterface <IAITool>(assemblies);
 }