Пример #1
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            ICollection <string> developers = Database.GetDevelopers(game.Id);

            foreach (string developer in developers)
            {
                if (!Developers.Contains(developer) && !AllDevelopers)
                {
                    continue;
                }

                if (DevCount(developer) >= MinCount)
                {
                    game.AddCategory(games.GetCategory(GetCategoryName(developer)));
                }
            }

            ICollection <string> publishers = Database.GetPublishers(game.Id);

            foreach (string publisher in publishers)
            {
                if (!Publishers.Contains(publisher) && !AllPublishers)
                {
                    continue;
                }

                if (PubCount(publisher) >= MinCount)
                {
                    game.AddCategory(games.GetCategory(GetCategoryName(publisher)));
                }
            }

            return(AutoCatResult.Success);
        }
Пример #2
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (!db.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            AppPlatforms platforms = entry.Platforms;

            if (Windows && platforms.HasFlag(AppPlatforms.Windows))
            {
                game.AddCategory(games.GetCategory(GetCategoryName("Windows")));
            }

            if (Mac && platforms.HasFlag(AppPlatforms.Mac))
            {
                game.AddCategory(games.GetCategory(GetCategoryName("Mac")));
            }

            if (Linux && platforms.HasFlag(AppPlatforms.Linux))
            {
                game.AddCategory(games.GetCategory(GetCategoryName("Linux")));
            }

            if (Linux && platforms.HasFlag(AppPlatforms.Linux))
            {
                game.AddCategory(games.GetCategory(GetCategoryName("SteamOS")));
            }

            return(AutoCatResult.Success);
        }
Пример #3
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter) || entry.Aspects.Count == 0)
            {
                return(AutoCatResult.Filtered);
            }


            foreach (var aspect in entry.Aspects)
            {
                game.AddCategory(games.GetCategory(GetCategoryLabel(aspect)));
            }

            return(AutoCatResult.Success);
        }
Пример #4
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Database.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            int year = Database.GetReleaseYear(game.Id);

            if (year > 0 || IncludeUnknown)
            {
                game.AddCategory(games.GetCategory(GetProcessedString(year)));
            }

            return(AutoCatResult.Success);
        }
Пример #5
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (curatorRecommendations == null || curatorRecommendations.Count == 0)
            {
                return(AutoCatResult.Failure);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (curatorRecommendations.ContainsKey(game.Id) && IncludedRecommendations.Contains(curatorRecommendations[game.Id]))
            {
                string   typeName = Utility.GetEnumDescription(curatorRecommendations[game.Id]);
                Category c        = games.GetCategory(GetProcessedString(typeName));
                game.AddCategory(c);
            }

            return(AutoCatResult.Success);
        }
Пример #6
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            ICollection <string> gameFlags  = Database.GetFlagList(game.Id);
            IEnumerable <string> categories = gameFlags.Intersect(IncludedFlags);

            foreach (string catString in categories)
            {
                Category c = games.GetCategory(GetCategoryName(catString));
                game.AddCategory(c);
            }

            return(AutoCatResult.Success);
        }
Пример #7
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            string result = null;

            float hltbMain          = Db.Games[game.Id].HltbMain / 60.0f;
            float hltbExtras        = Db.Games[game.Id].HltbExtras / 60.0f;
            float hltbCompletionist = Db.Games[game.Id].HltbCompletionist / 60.0f;

            if (IncludeUnknown && (hltbMain == 0.0f) && (hltbExtras == 0.0f) && (hltbCompletionist == 0.0f))
            {
                result = UnknownText;
            }
            else
            {
                foreach (HltbRule rule in Rules)
                {
                    if (CheckRule(rule, hltbMain, hltbExtras, hltbCompletionist))
                    {
                        result = rule.Name;
                        break;
                    }
                }
            }

            if (result != null)
            {
                result = GetProcessedString(result);
                game.AddCategory(Games.GetCategory(result));
            }
            return(AutoCatResult.Success);
        }
Пример #8
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (RemoveOtherGenres && genreCategories != null)
            {
                game.RemoveCategory(genreCategories);
            }

            ICollection <string> genreList = Database.GetGenreList(game.Id, MAX_PARENT_DEPTH, TagFallback);

            List <Category> categories = new List <Category>();
            int             max        = MaxCategories;

            int i = 0;

            foreach (string genre in genreList)
            {
                if (MaxCategories != 0 && i >= max)
                {
                    continue;
                }

                if (!IgnoredGenres.Contains(genre))
                {
                    categories.Add(games.GetCategory(GetCategoryName(genre)));
                }
                else
                {
                    max++; // ignored genres don't contribute to max
                }

                i++;
            }

            game.AddCategory(categories);

            return(AutoCatResult.Success);
        }
Пример #9
0
        /// <summary>
        /// </summary>
        /// <param name="game"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id) || (Db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (RemoveOtherGenres && (_genreCategories != null))
            {
                game.RemoveCategory(_genreCategories);
            }

            List <string> genreList = Db.GetGenreList(game.Id, MaxParentDepth, TagFallback);

            if ((genreList != null) && (genreList.Count > 0))
            {
                List <Category> categories = new List <Category>();
                int             max        = MaxCategories;
                for (int i = 0; (i < genreList.Count) && ((MaxCategories == 0) || (i < max)); i++)
                {
                    if (!IgnoredGenres.Contains(genreList[i]))
                    {
                        categories.Add(Games.GetCategory(GetProcessedString(genreList[i])));
                    }
                    else
                    {
                        max++; // ignored genres don't contribute to max
                    }
                }

                game.AddCategory(categories);
            }

            return(AutoCatResult.Success);
        }
Пример #10
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            string result = null;

            float hltbMain          = entry.HltbMain / 60.0f;
            float hltbExtras        = entry.HltbExtras / 60.0f;
            float hltbCompletionist = entry.HltbCompletionists / 60.0f;

            if (IncludeUnknown && hltbMain == 0.0f && hltbExtras == 0.0f && hltbCompletionist == 0.0f)
            {
                result = UnknownText;
            }
            else
            {
                foreach (HowLongToBeatRule rule in Rules)
                {
                    if (!CheckRule(rule, hltbMain, hltbExtras, hltbCompletionist))
                    {
                        continue;
                    }

                    result = rule.Name;
                    break;
                }
            }

            if (result == null)
            {
                return(AutoCatResult.Success);
            }

            result = GetCategoryName(result);
            game.AddCategory(games.GetCategory(result));

            return(AutoCatResult.Success);
        }
Пример #11
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (db == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!db.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            string result = null;

            foreach (HoursPlayedRule rule in Rules)
            {
                if (!CheckRule(rule, game.HoursPlayed))
                {
                    continue;
                }

                result = rule.Name;
                break;
            }

            if (result == null)
            {
                return(AutoCatResult.Success);
            }

            result = GetCategoryName(result);
            game.AddCategory(games.GetCategory(result));

            return(AutoCatResult.Success);
        }
Пример #12
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (db == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!db.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            string cat = game.Name.Substring(0, 1);

            cat = cat.ToUpper();
            if (SkipThe && cat == "T" && game.Name.Substring(0, 4).ToUpper() == "THE ")
            {
                cat = game.Name.Substring(4, 1).ToUpper();
            }

            if (GroupNumbers && char.IsDigit(cat[0]))
            {
                cat = "#";
            }
            else if (GroupNonEnglishCharacters && !string.IsNullOrEmpty(GroupNonEnglishCharactersText) && Regex.IsMatch(cat, "[^a-z0-9]", RegexOptions.IgnoreCase))
            {
                cat = GroupNonEnglishCharactersText;
            }

            if (Prefix != null)
            {
                cat = Prefix + cat;
            }

            game.AddCategory(games.GetCategory(cat));

            return(AutoCatResult.Success);
        }
Пример #13
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id) || (Db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            List <string> gameTags = Db.GetTagList(game.Id);

            if (gameTags != null)
            {
                int added = 0;
                for (int index = 0; (index < gameTags.Count) && ((MaxTags == 0) || (added < MaxTags)); index++)
                {
                    if (IncludedTags.Contains(gameTags[index]))
                    {
                        game.AddCategory(Games.GetCategory(GetProcessedString(gameTags[index])));
                        added++;
                    }
                }
            }

            return(AutoCatResult.Success);
        }
Пример #14
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (db == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!db.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            Collection <string> gameTags = db.GetTagList(game.Id);

            int added = 0;

            for (int index = 0; index < gameTags.Count && (MaxTags == 0 || added < MaxTags); index++)
            {
                if (!IncludedTags.Contains(gameTags[index]))
                {
                    continue;
                }

                game.AddCategory(games.GetCategory(GetCategoryName(gameTags[index])));
                added++;
            }

            return(AutoCatResult.Success);
        }
Пример #15
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            string cat = game.Name.Substring(0, 1);

            cat = cat.ToUpper();
            if (SkipThe && (cat == "T") && (game.Name.Substring(0, 4).ToUpper() == "THE "))
            {
                cat = game.Name.Substring(4, 1).ToUpper();
            }
            if (GroupNumbers && char.IsDigit(cat[0]))
            {
                cat = "#";
            }
            if (Prefix != null)
            {
                cat = Prefix + cat;
            }

            game.AddCategory(Games.GetCategory(cat));

            return(AutoCatResult.Success);
        }
Пример #16
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Database.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            int added = 0;

            foreach (string gameTag in Database.GetTagList(game.Id))
            {
                if (MaxTags != 0 && added >= MaxTags)
                {
                    continue;
                }

                if (!IncludedTags.Contains(gameTag))
                {
                    continue;
                }

                game.AddCategory(games.GetCategory(GetCategoryName(gameTag)));
                added++;
            }

            return(AutoCatResult.Success);
        }
Пример #17
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id) || (Db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            List <string>        gameFlags  = Db.GetFlagList(game.Id) ?? new List <string>();
            IEnumerable <string> categories = gameFlags.Intersect(IncludedFlags);

            foreach (string catString in categories)
            {
                Category c = Games.GetCategory(GetProcessedString(catString));
                game.AddCategory(c);
            }

            return(AutoCatResult.Success);
        }
Пример #18
0
        /// <inheritdoc />
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (db == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!db.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (RemoveAllCategories)
            {
                game.ClearCategories();
            }
            else if (RemoveCategories != null)
            {
                List <Category> removed = new List <Category>();

                foreach (string category in RemoveCategories)
                {
                    Category c = gamelist.GetCategory(category);
                    if (!game.ContainsCategory(c))
                    {
                        continue;
                    }

                    game.RemoveCategory(c);
                    removed.Add(c);
                }

                foreach (Category c in removed)
                {
                    if (c.Count == 0)
                    {
                        gamelist.RemoveCategory(c);
                    }
                }
            }

            if (AddCategories == null)
            {
                return(AutoCatResult.Success);
            }

            foreach (string category in AddCategories)
            // add Category, or create it if it doesn't exist
            {
                game.AddCategory(gamelist.GetCategory(GetCategoryName(category)));
            }

            return(AutoCatResult.Success);
        }
Пример #19
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id) || (Db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            List <string> developers = Db.GetDevelopers(game.Id);

            if (developers != null)
            {
                foreach (string developer in developers)
                {
                    if (Developers.Contains(developer) || AllDevelopers)
                    {
                        if (DevCount(developer) >= MinCount)
                        {
                            game.AddCategory(Games.GetCategory(GetProcessedString(developer)));
                        }
                    }
                }
            }

            List <string> publishers = Db.GetPublishers(game.Id);

            if (publishers != null)
            {
                foreach (string publisher in publishers)
                {
                    if (Publishers.Contains(publisher) || AllPublishers)
                    {
                        if (PubCount(publisher) >= MinCount)
                        {
                            game.AddCategory(Games.GetCategory(GetProcessedString(publisher)));
                        }
                    }
                }
            }

            return(AutoCatResult.Success);
        }
Пример #20
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id) || (Db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (RemoveAllCategories)
            {
                game.ClearCategories();
            }
            else if (RemoveCategories != null)
            {
                List <Category> removed = new List <Category>();

                foreach (string category in RemoveCategories)
                {
                    Category c = _gamelist.GetCategory(category);
                    if (game.ContainsCategory(c))
                    {
                        game.RemoveCategory(c);
                        removed.Add(c);
                    }
                }

                foreach (Category c in removed)
                {
                    if (c.Count == 0)
                    {
                        _gamelist.RemoveCategory(c);
                    }
                }
            }

            if (AddCategories != null)
            {
                foreach (string category in AddCategories)
                {
                    // add Category, or create it if it doesn't exist
                    game.AddCategory(_gamelist.GetCategory(GetProcessedString(category)));
                }
            }

            return(AutoCatResult.Success);
        }
Пример #21
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (Games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (Db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!Db.Contains(game.Id))
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            int score   = Db.Games[game.Id].ReviewPositivePercentage;
            int reviews = Db.Games[game.Id].ReviewTotal;

            if (UseWilsonScore && (reviews > 0))
            {
                // calculate the lower bound of the Wilson interval for 95 % confidence
                // see http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
                // $$ w^\pm = \frac{1}{1+\frac{z^2}{n}}
                // \left( \hat p + \frac{z^2}{2n} \pm z \sqrt{ \frac{\hat p (1 - \hat p)}{n} + \frac{z^2}{4n^2} } \right)$$
                // where
                // $\hat p$ is the observed fraction of positive ratings (proportion of successes),
                // $n$ is the total number of ratings (the sample size), and
                // $z$ is the $1-{\frac {\alpha}{2}}$ quantile of a standard normal distribution
                // for 95% confidence, the $z = 1.96$
                double
                       z = 1.96; // normal distribution of (1-(1-confidence)/2), i.e. normal distribution of 0.975 for 95% confidence
                double p = score / 100.0;
                double n = reviews;
                p = Math.Round(100 * (((p + ((z * z) / (2 * n))) -
                                       (z * Math.Sqrt(((p * (1 - p)) + ((z * z) / (4 * n))) / n))) /
                                      (1 + ((z * z) / n))));
                // debug: System.Windows.Forms.MessageBox.Show("score " + score + " of " + reviews + " is\tp = " + p + "\n");
                score = Convert.ToInt32(p);
            }
            string result = (from rule in Rules where CheckRule(rule, score, reviews) select rule.Name)
                            .FirstOrDefault();

            if (result != null)
            {
                result = GetProcessedString(result);
                game.AddCategory(Games.GetCategory(result));
            }
            return(AutoCatResult.Success);
        }