Esempio n. 1
0
        public async Task <CartesianChartConfigModel> PersonalDivideByBossRoundComparision(GranularityModel granularity)
        {
            var personsGrouping = GetPersonalDictionary(granularity, out var titlePrefix);

            var personBossDic = personsGrouping.ToDictionary(k => k.Key,
                                                             k =>
            {
                var dic = new Dictionary <int, int>();
                foreach (var challengeModel in k)
                {
                    if (dic.ContainsKey(challengeModel.BossNum))
                    {
                        dic[challengeModel.BossNum] += challengeModel.Damage;
                    }
                    else
                    {
                        dic.Add(challengeModel.BossNum, challengeModel.Damage);
                    }
                }

                return(dic);
            });

            var list = new List <PersonalDamageModel>();

            foreach (var kvp in personBossDic)
            {
                var cycleModel = new PersonalDamageModel
                {
                    Name = $"{await QQService.GetQqNickNameAsync(kvp.Key)} ({kvp.Key})"
                };

                for (int i = 0; i < 5; i++)
                {
                    var bossNum    = cycleModel.Damages.Count + 1;
                    var bossDamage = kvp.Value.ContainsKey(bossNum) ? kvp.Value[bossNum] : 0L;
                    cycleModel.Damages.Add((int)bossDamage);
                }

                list.Add(cycleModel);
            }

            list = list.OrderBy(k => k.Damages.Sum()).ToList();

            var configModel = GetSharedConfigModel(titlePrefix, list);

            for (int i = 0; i < 5; i++)
            {
                configModel.SeriesCollection.Add(new StackedRowSeries
                {
                    Title      = $"BOSS {i + 1}",
                    Values     = new ChartValues <int>(list.Select(k => k.Damages[i]).ToList()),
                    DataLabels = true
                });
            }

            ConfigAxises(configModel);

            return(configModel);
        }
Esempio n. 2
0
        public async Task <CartesianChartConfigModel> PersonalDivideByChallengeTimesDayComparision(
            GranularityModel granularity)
        {
            var personsGrouping = GetPersonalDictionary(granularity, out var titlePrefix);

            var list = new List <PersonalDamageModel>();

            foreach (var kvp in personsGrouping)
            {
                var qqId = kvp.Key;

                var byDate = kvp.GroupBy(k => k.ChallengeTime.AddHours(-5).Date);
                // multi date support

                var damageModel = new PersonalDamageModel
                {
                    Name    = $"{await QQService.GetQqNickNameAsync(qqId)} ({qqId})",
                    Damages = new List <int> {
                        0, 0, 0, 0, 0, 0
                    }
                };

                foreach (var grouping in byDate)
                {
                    int i = 0;
                    foreach (var challengeModel in grouping)
                    {
                        if (challengeModel.IsContinue)
                        {
                            if (i % 2 == 0)
                            {
                                i++;
                            }
                            damageModel.Damages[i] += challengeModel.Damage;
                        }
                        else
                        {
                            if (i % 2 != 0)
                            {
                                i++;
                            }
                            damageModel.Damages[i] += challengeModel.Damage;
                        }

                        i++;
                    }
                }

                list.Add(damageModel);
            }

            list = list.OrderBy(k => k.Damages.Sum()).ToList();

            var configModel = GetSharedConfigModel(titlePrefix, list);

            for (int i = 0; i < 6; i++)
            {
                var challengeIndex = i / 2 + 1;
                configModel.SeriesCollection.Add(new StackedRowSeries
                {
                    Title      = i % 2 == 0 ? $"第{challengeIndex}刀" : $"第{challengeIndex}刀(补偿刀)",
                    Values     = new ChartValues <int>(list.Select(k => k.Damages[i]).ToList()),
                    DataLabels = true
                });
            }

            ConfigAxises(configModel);

            return(configModel);
        }