예제 #1
0
            public async Task ClaimSkillPointsAsync()
            {
                var userInfo  = Context.User;
                var character = await _charService.GetCharacterAsync(userInfo.Id);

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

                    return;
                }

                if (!character.IsReset)
                {
                    await ReplyAsync(string.Format(Messages.ERR_SKILLS_NONE_TO_CLAIM, userInfo.Mention));

                    return;
                }

                if (!_skillsService.AreSkillsSet(character))
                {
                    await ReplyAsync(string.Format(Messages.ERR_SKILLS_NOT_FOUND, userInfo.Mention));

                    return;
                }

                int pointsPerLevel = _skillsService.CalculateSkillPoints(character.Special.Intelligence);
                int totalPoints    = pointsPerLevel * (character.Level - 1);

                if (totalPoints < 1)
                {
                    await ReplyAsync(string.Format(Messages.ERR_SKILLS_NONE_TO_CLAIM, userInfo.Mention));

                    return;
                }

                character.SkillPoints += totalPoints;
                character.IsReset      = false;
                await _charService.SaveCharacterAsync(character);

                await ReplyAsync(string.Format(Messages.SKILLS_POINTS_CLAIMED, totalPoints, userInfo.Mention));
            }