Beispiel #1
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.成员);
        }
        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);
        }
Beispiel #3
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))})");
        }
Beispiel #4
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);
        }
Beispiel #5
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());
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
Beispiel #12
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;
        }
Beispiel #13
0
        protected override void ScheduleDo(SchedulerTimer timer)
        {
            AutofacSvc.Resolve <HonorSvc>().RefreshData();

            timer.Interval = (DateTime.Now.Date.AddDays(1) - DateTime.Now).TotalMilliseconds;
        }