Пример #1
0
        private async Task <bool> CheckLevelUpEligibility(ParabotUser parabotUser)
        {
            LevelRepository levelRepo = new LevelRepository();
            var             levelList = await levelRepo.GetExpRequirements();

            var levelUpRequirements = levelList.FirstOrDefault(l => l.Level == parabotUser.Level + 1);

            if (levelUpRequirements == null)
            {
                levelUpRequirements = new ParabotLevel(parabotUser.Level + 1, 50);
            }
            Log.Debug($"Level {parabotUser.Level} user {parabotUser.UserName} with {parabotUser.Exp} experience requires {levelUpRequirements.ExpRequirement} experience to level up to {levelUpRequirements.Level}");
            return(parabotUser.Exp >= levelUpRequirements.ExpRequirement ? true : false);
        }
Пример #2
0
        public async Task <ParabotLevel> GetLevelRequirement(ParabotUser parabotUser)
        {
            LevelRepository levelRepo  = new LevelRepository(parabotUser);
            var             resultList = await levelRepo.GetExpRequirements();

            switch (resultList.Count)
            {
            case 0:
                Log.Error("Error finding Exp Requirements collection");
                return(null);

            default:
                Log.Information("Found Exp Requirements collection");
                return(resultList.FirstOrDefault(level => level.Level == parabotUser.Level + 1));
            }
        }