示例#1
0
        public async Task ViewStatisticsAsync(IUser user = null)
        {
            user = user ?? Context.User;
            var result = await _statController.ShowStatisticsAsync(user.Id);

            if (!result.IsSuccess)
            {
                await ReplyAsync(result.Message);

                return;
            }

            StringBuilder output    = new StringBuilder();
            var           viewModel = (ShowCharacterStatisticsViewModel)result.ViewModel;

            foreach (var attrib in viewModel.Statistics.Keys.OrderByDescending(x => x.Order))
            {
                // Example: "Strength: 5" or "Strength: N/A"
                output.Append($"__**{attrib.Name}: {attrib.Value?.ToString() ?? "N/A"}**__\n");

                if (attrib.IsProficient.HasValue && attrib.IsProficient.Value)
                {
                    output.Append("*");
                }

                // Loop through associated skills with attribute
                foreach (var skill in viewModel.Statistics[attrib].OrderByDescending(x => x.Order))
                {
                    // Example: "Powerlifting: 50" or "Powerlifting: N/A"
                    output.Append($"**{skill.Name}:** {skill.Value?.ToString() ?? "N/A"}");

                    if (skill.IsProficient.HasValue && skill.IsProficient.Value)
                    {
                        output.Append("*");
                    }

                    output.Append("\n");
                }
                output.Append("\n");
            }

            if (viewModel.AttributePoints > 0)
            {
                output.Append($"*You have {viewModel.AttributePoints} attribute points left to spend!*\n");
            }

            if (viewModel.SkillPoints > 0)
            {
                output.Append($"*You have {viewModel.SkillPoints} skill points left to spend!*\n");
            }

            if (!string.IsNullOrWhiteSpace(viewModel.ProgressionInformation))
            {
                output.Append($"Progression info:\n{viewModel.ProgressionInformation}\n");
            }

            EmbedBuilder eb = new EmbedBuilder();

            eb.WithTitle($"{viewModel.CharacterName}'s Statistics");
            eb.WithDescription(output.ToString());
            await ReplyAsync(embed : eb.Build());
        }