コード例 #1
0
        public async Task ShowCharacterAsync(IUser targetUser = null)
        {
            var userInfo  = Context.User;
            var character = targetUser == null
                ? await _charService.GetCharacterAsync(userInfo.Id)
                : await _charService.GetCharacterAsync(targetUser.Id);

            if (character == null)
            {
                await ReplyAsync(string.Format(Messages.ERR_CHAR_NOT_FOUND, userInfo.Mention));

                return;
            }

            var level          = _expService.CalculateLevelForExperience(character.Experience);
            var expToNextLevel = _expService.CalculateRemainingExperienceToNextLevel(character.Experience);

            var description = string.IsNullOrEmpty(character.Description) ? "No description." : character.Description;
            var story       = string.IsNullOrEmpty(character.Story) ? "No story." : character.Story;

            var embed = EmbedHelper.BuildBasicEmbed($"{character.Name}",
                                                    $"**Description:** {description}\n" +
                                                    $"**Story:** ($char story)\n" +
                                                    $"**Level:** {level}\n" +
                                                    $"**Experience:** {character.Experience}\n" +
                                                    $"**To Next Level:** {expToNextLevel}\n" +
                                                    $"**Caps:** {character.Money}");

            await ReplyAsync(userInfo.Mention, embed : embed);
        }
コード例 #2
0
ファイル: RoleplayModule.cs プロジェクト: mrredcon/FalloutRPG
        public async Task ShowHighScoresAsync()
        {
            var userInfo = Context.User;
            var charList = await _charService.GetHighScoresAsync();

            var strBuilder = new StringBuilder();

            /*for (var i = 0; i < charList.Count; i++)
             * {
             *  var level = _expService.CalculateLevelForExperience(charList[i].Experience);
             *
             *  strBuilder.Append(
             *      $"**{i + 1}:** {charList[i].FirstName} {charList[i].LastName}" +
             *      $" | Level: {level}" +
             *      $" | Experience: {charList[i].Experience}\n");
             * }
             *
             * var embed = EmbedHelper.BuildBasicEmbed("Command: $highscores", strBuilder.ToString());*/

            var fieldTitlesList   = new List <string>();
            var fieldContentsList = new List <string>();

            for (var i = 0; i < charList.Count; i++)
            {
                var level = _expService.CalculateLevelForExperience(charList[i].Experience);
                fieldTitlesList.Add($"{i + 1}: {charList[i].Name}");
                fieldContentsList.Add($"Level {level} / {charList[i].Experience} XP");
            }

            var embed = EmbedHelper.BuildBasicEmbedWithFields("Command: $hiscores", string.Empty, fieldTitlesList.ToArray(), fieldContentsList.ToArray());

            await ReplyAsync(userInfo.Mention, embed : embed);
        }
コード例 #3
0
        public async Task <RuntimeResult> ShowCharacterAsync(IUser targetUser = null)
        {
            var userInfo  = Context.User;
            var character = targetUser == null
                ? await _charService.GetCharacterAsync(userInfo.Id)
                : await _charService.GetCharacterAsync(targetUser.Id);

            if (character == null)
            {
                return(CharacterResult.CharacterNotFound());
            }

            var level          = _expService.CalculateLevelForExperience(character.Experience);
            var expToNextLevel = _expService.CalculateRemainingExperienceToNextLevel(character.Experience);

            if (!ExperienceService.UseOldProgression)
            {
                expToNextLevel = (level + 1) * 1000 - character.Experience;
            }

            var description = string.IsNullOrEmpty(character.Description) ? "No description." : character.Description;
            var story       = string.IsNullOrEmpty(character.Story) ? "No story." : character.Story;

            var embed = EmbedHelper.BuildBasicEmbed($"{character.Name}",
                                                    $"**Description:** {description}\n" +
                                                    $"**Story:** ($char story)\n" +
                                                    $"**Level:** {level}\n" +
                                                    $"**Experience:** {character.Experience}\n" +
                                                    $"**To Next Level:** {expToNextLevel}\n" +
                                                    $"**Caps:** {character.Money}");

            await ReplyAsync(userInfo.Mention, embed : embed);

            return(GenericResult.FromSilentSuccess());
        }