IncludeGame() public method

public IncludeGame ( Filter f ) : bool
f Filter
return bool
コード例 #1
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);
            }

            VrSupport vrSupport = db.GetVrSupport(game.Id);

            vrSupport.Headsets = vrSupport.Headsets ?? new List <string>();
            vrSupport.Input    = vrSupport.Input ?? new List <string>();
            vrSupport.PlayArea = vrSupport.PlayArea ?? new List <string>();

            IEnumerable <string> headsets = vrSupport.Headsets.Intersect(IncludedVrSupportFlags.Headsets);
            IEnumerable <string> input    = vrSupport.Input.Intersect(IncludedVrSupportFlags.Input);
            IEnumerable <string> playArea = vrSupport.PlayArea.Intersect(IncludedVrSupportFlags.PlayArea);

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

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

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

            return(AutoCatResult.Success);
        }
コード例 #2
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Program.Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }
            if (game == null)
            {
                Program.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);
        }
コード例 #3
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 );
            if( gameFlags == null ) gameFlags = 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;
        }
コード例 #4
0
ファイル: AutoCatGroup.cs プロジェクト: satma/depressurizer
        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);
            }

            return(AutoCatResult.Success);
        }
コード例 #5
0
ファイル: AutoCatHltb.cs プロジェクト: ppm6/Depressurizer
        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 (Hltb_Rule 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);
        }
コード例 #6
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 year = db.GetReleaseYear(game.Id);
            if (year > 0 || IncludeUnknown)
            {
                game.AddCategory(games.GetCategory(GetProcessedString(year)));
            }

            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) || 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, MAX_PARENT_DEPTH, 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);
        }
コード例 #8
0
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Program.Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

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

            if (game == null)
            {
                Program.Logger.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);
            }

            LanguageSupport languageSupport = db.Games[game.Id].LanguageSupport;

            IEnumerable <string> interfaceLanguage = languageSupport.Interface.Intersect(IncludedLanguages.Interface);

            foreach (string catString in interfaceLanguage)
            {
                Category c = games.GetCategory(GetProcessedString(catString, "Interface"));
                game.AddCategory(c);
            }

            foreach (string catString in IncludedLanguages.Subtitles)
            {
                if (languageSupport.Subtitles.Contains(catString) || languageSupport.Subtitles.Count == 0 && languageSupport.FullAudio.Contains(catString) || languageSupport.FullAudio.Count == 0 && languageSupport.Interface.Contains(catString))
                {
                    game.AddCategory(games.GetCategory(GetProcessedString(catString, "Subtitles")));
                }
            }

            foreach (string catString in IncludedLanguages.FullAudio)
            {
                if (languageSupport.FullAudio.Contains(catString) || languageSupport.FullAudio.Count == 0 && languageSupport.Subtitles.Contains(catString) || languageSupport.Subtitles.Count == 0 && languageSupport.Interface.Contains(catString))
                {
                    game.AddCategory(games.GetCategory(GetProcessedString(catString, "Full Audio")));
                }
            }

            return(AutoCatResult.Success);
        }
コード例 #9
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);
        }
コード例 #10
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 (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) || (db.Games[game.Id].LastStoreScrape == 0))
            {
                return(AutoCatResult.NotInDatabase);
            }

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

            List <string> gameFlags = db.GetFlagList(game.Id);

            if (gameFlags == null)
            {
                gameFlags = 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);
        }
コード例 #11
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 (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

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

            AppPlatforms platforms = db.Games[game.Id].Platforms;

            if (Windows && ((platforms & AppPlatforms.Windows) != 0))
            {
                game.AddCategory(games.GetCategory(GetProcessedString("Windows")));
            }

            if (Windows && ((platforms & AppPlatforms.Mac) != 0))
            {
                game.AddCategory(games.GetCategory(GetProcessedString("Mac")));
            }

            if (Windows && ((platforms & AppPlatforms.Linux) != 0))
            {
                game.AddCategory(games.GetCategory(GetProcessedString("Linux")));
            }

            if (Windows && ((platforms & AppPlatforms.Linux) != 0))
            {
                game.AddCategory(games.GetCategory(GetProcessedString("SteamOS")));
            }

            return(AutoCatResult.Success);
        }
コード例 #12
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 (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);
            }

            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);
        }
コード例 #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))
            {
                return(AutoCatResult.NotInDatabase);
            }

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

            int    score   = db.Games[game.Id].ReviewPositivePercentage;
            int    reviews = db.Games[game.Id].ReviewTotal;
            string result  = null;

            foreach (UserScore_Rule rule in Rules)
            {
                if (CheckRule(rule, score, reviews))
                {
                    result = rule.Name;
                    break;
                }
            }

            if (result != null)
            {
                result = GetProcessedString(result);
                game.AddCategory(games.GetCategory(result));
            }
            return(AutoCatResult.Success);
        }
コード例 #14
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;
        }
コード例 #15
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 (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))
                    {
                        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);
        }
コード例 #16
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 year = db.GetReleaseYear( game.Id );
            if( year > 0 || IncludeUnknown ) {
                game.AddCategory( games.GetCategory( GetProcessedString( year ) ) );
            }

            return AutoCatResult.Success;
        }
コード例 #17
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))
            {
                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);
        }
コード例 #18
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;
        }
コード例 #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 ) ) return AutoCatResult.NotInDatabase;

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

            int score = db.Games[game.Id].ReviewPositivePercentage;
            int reviews = db.Games[game.Id].ReviewTotal;
            string result = null;
            foreach( UserScore_Rule rule in Rules ) {
                if( CheckRule( rule, score, reviews ) ) {
                    result = rule.Name;
                    break;
                }
            }

            if( result != null ) {
                result = GetProcessedString( result );
                game.AddCategory( games.GetCategory( result ) );
            }
            return AutoCatResult.Success;
        }
コード例 #20
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 (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> developers = db.GetDevelopers(game.Id);

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

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

            Collection <string> publishers = db.GetPublishers(game.Id);

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

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

            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;

            return AutoCatResult.Success;
        }
コード例 #22
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> devs = db.GetDevelopers(game.Id);

            if (devs != null)
            {
                for (int index = 0; index < devs.Count; index++)
                {
                    if (Developers.Contains(devs[index]) || AllDevelopers)
                    {
                        if (DevCount(devs[index]) >= MinCount) game.AddCategory(games.GetCategory(GetProcessedString(devs[index])));
                    }
                }
            }

            List<string> pubs = db.GetPublishers(game.Id);

            if (pubs != null)
            {
                for (int index = 0; index < pubs.Count; index++)
                {
                    if (Publishers.Contains(pubs[index]) || AllPublishers)
                    {
                        if (PubCount(pubs[index]) >= MinCount) game.AddCategory(games.GetCategory(GetProcessedString(pubs[index])));
                    }
                }
            }

            return AutoCatResult.Success;
        }
コード例 #23
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 = null;
            foreach( UserScore_Rule rule in Rules ) {
                if( CheckRule( rule, score, reviews ) ) {
                    result = rule.Name;
                    break;
                }
            }

            if( result != null ) {
                result = GetProcessedString( result );
                game.AddCategory( games.GetCategory( result ) );
            }
            return AutoCatResult.Success;
        }
コード例 #24
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> devs = db.GetDevelopers(game.Id);

            if (devs != null)
            {
                for (int index = 0; index < devs.Count; index++)
                {
                    if (Developers.Contains(devs[index]) || AllDevelopers)
                    {
                        if (DevCount(devs[index]) >= MinCount)
                        {
                            game.AddCategory(games.GetCategory(GetProcessedString(devs[index])));
                        }
                    }
                }
            }

            List <string> pubs = db.GetPublishers(game.Id);

            if (pubs != null)
            {
                for (int index = 0; index < pubs.Count; index++)
                {
                    if (Publishers.Contains(pubs[index]) || AllPublishers)
                    {
                        if (PubCount(pubs[index]) >= MinCount)
                        {
                            game.AddCategory(games.GetCategory(GetProcessedString(pubs[index])));
                        }
                    }
                }
            }

            return(AutoCatResult.Success);
        }
コード例 #25
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 (Hltb_Rule 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;
        }
コード例 #26
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;
        }
コード例 #27
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( RemoveOtherGenres && genreCategories != null ) {
                game.RemoveCategory( genreCategories );
            }

            List<string> genreList = db.GetGenreList( game.Id, depth:MAX_PARENT_DEPTH, tagFallback: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;
        }
コード例 #28
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 = null;

            foreach (UserScore_Rule rule in Rules)
            {
                if (CheckRule(rule, score, reviews))
                {
                    result = rule.Name;
                    break;
                }
            }

            if (result != null)
            {
                result = GetProcessedString(result);
                game.AddCategory(games.GetCategory(result));
            }
            return(AutoCatResult.Success);
        }
コード例 #29
0
ファイル: MainForm.cs プロジェクト: Theo47/depressurizer
        /// <summary>
        /// Checks to see if a game should currently be displayed, based on the state of the category list.
        /// </summary>
        /// <param name="g">Game to check</param>
        /// <returns>True if it should be displayed, false otherwise</returns>
        bool ShouldDisplayGame(GameInfo g)
        {
            if (currentProfile == null) return false;
            if (mtxtSearch.Text != string.Empty && g.Name.IndexOf(mtxtSearch.Text, StringComparison.CurrentCultureIgnoreCase) == -1) return false;
            if (!currentProfile.GameData.Games.ContainsKey(g.Id)) return false;
            if (g.Id < 0 && !currentProfile.IncludeShortcuts) return false;

            if (lstCategories.SelectedItems.Count == 0) return false;

            if (AdvancedCategoryFilter)
            {
                return g.IncludeGame(advFilter);
            }

            if (g.Hidden)
            {
                return (lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_Hidden);
            }

            if (lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_Uncategorized)
            {
                return !g.HasCategories();
            }

            if (lstCategories.SelectedItems[0].Tag is Category)
            {
                if (((Category) lstCategories.SelectedItems[0].Tag).Name == GlobalStrings.MainForm_Favorite)
                    return g.IsFavorite();
                return g.ContainsCategory(lstCategories.SelectedItems[0].Tag as Category);
            }
            else
            {
                if (lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_All)
                {
                    return true;
                }
                if (lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_Uncategorized)
                {
                    return !g.HasCategories();
                }
            }

            return false;
        }