Ejemplo n.º 1
0
            public async Task <RuntimeResult> UpgradeSpecialAsync(Special special)
            {
                var userInfo  = Context.User;
                var character = await _charService.GetCharacterAsync(userInfo.Id);

                if (character == null)
                {
                    return(CharacterResult.CharacterNotFound());
                }
                if (!_specService.IsSpecialSet(character))
                {
                    return(StatisticResult.SpecialNotSet());
                }

                return(_specService.UpgradeSpecial(character, special));
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 3
0
            public async Task <RuntimeResult> InitializeStatisticsAsync()
            {
                if (!_progOptions.UseOldProgression ||
                    !_progOptions.OldProgression.UseNewVegasRules)
                {
                    return(StatisticResult.NotUsingNewVegasRules());
                }

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

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

                if (!_specService.IsSpecialSet(character))
                {
                    return(StatisticResult.SpecialNotSet());
                }

                // Makes sure at least one skill has a value, otherwise the character might not have tagged their skills yet
                // We can't use !AreSkillsSet because it assumes that EVERY skill (including the brand new one) is greater than 0 at this point
                // If a new skill just got added, it's going to be 0 for everybody!
                if (character.Skills.Count(x => x.Value > 0) < 1)
                {
                    return(StatisticResult.SkillsNotSet());
                }

                // Now we check if all the skills count is the same, because if this is true, there aren't any new skills to initialize,
                // running this command is pointless and adds unnecessary risk
                if (character.Skills.Count == StatisticsService.Statistics.OfType <Skill>().Count())
                {
                    return(StatisticResult.SkillsAlreadyTagged());
                }

                _statsService.InitializeStatistics(character.Statistics);
                _skillsService.InitializeSkills(character, true);
                await _charService.SaveCharacterAsync(character);

                return(GenericResult.FromSuccess("Character skills initialized successfully."));
            }