Beispiel #1
0
            public async Task <RuntimeResult> SpendSkillPointsAsync(Skill skill, int points)
            {
                if (!ExperienceService.UseOldProgression)
                {
                    return(StatisticResult.NotUsingOldProgression());
                }

                var userInfo  = Context.User;
                var character = await _charService.GetCharacterAsync(userInfo.Id);

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

                if (!_skillsService.AreSkillsSet(character))
                {
                    return(StatisticResult.SkillsNotSet());
                }

                if (points < 1)
                {
                    return(GenericResult.FromError(Messages.ERR_SKILLS_POINTS_BELOW_ONE));
                }

                if (points > character.ExperiencePoints)
                {
                    return(GenericResult.FromError(Exceptions.CHAR_NOT_ENOUGH_SKILL_POINTS));
                }

                var skillVal = _statsService.GetStatistic(character, skill);

                if ((skillVal + points) > _roleplayOptions.SkillMax)
                {
                    return(GenericResult.FromError(Exceptions.CHAR_SKILL_POINTS_GOES_OVER_MAX));
                }

                _statsService.SetStatistic(character, skill, skillVal + points);
                character.ExperiencePoints -= points;

                await _charService.SaveCharacterAsync(character);

                return(GenericResult.FromSuccess(Messages.SKILLS_SPEND_POINTS_SUCCESS));
            }
Beispiel #2
0
            public async Task <RuntimeResult> ClaimSkillPointsAsync()
            {
                if (!ExperienceService.UseOldProgression)
                {
                    return(StatisticResult.NotUsingOldProgression());
                }

                var userInfo  = Context.User;
                var character = await _charService.GetCharacterAsync(userInfo.Id);

                if (character == null)
                {
                    return(CharacterResult.CharacterNotFound());
                }
                if (!character.IsReset)
                {
                    return(GenericResult.FromError(Messages.ERR_SKILLS_NONE_TO_CLAIM));
                }
                if (!_specService.IsSpecialSet(character))
                {
                    return(StatisticResult.SpecialNotSet());
                }
                if (!_skillsService.AreSkillsSet(character))
                {
                    return(StatisticResult.SkillsNotSet());
                }

                _statsService.InitializeStatistics(character.Statistics);

                character.ExperiencePoints = 0;
                var intelligence = _statsService.GetStatistic(character, Globals.StatisticFlag.Intelligence);

                for (int level = 1; level <= character.Level; level++)
                {
                    character.ExperiencePoints += _expService.CalculateSkillPoints(level, intelligence);
                }

                character.IsReset = false;
                await _charService.SaveCharacterAsync(character);

                return(GenericResult.FromSuccess(string.Format(Messages.SKILLS_POINTS_CLAIMED, character.ExperiencePoints)));
            }