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); }
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); }
private static void AddGameFromXmlNode(XmlNode node, Profile profile, int profileVersion) { int id; if (XmlUtil.TryGetIntFromNode(node[XmlName_Game_Id], out id)) { GameListingSource source = XmlUtil.GetEnumFromNode(node[XmlName_Game_Source], GameListingSource.Unknown); if ((source < GameListingSource.Manual) && profile.IgnoreList.Contains(id)) { return; } string name = XmlUtil.GetStringFromNode(node[XmlName_Game_Name], null); GameInfo game = new GameInfo(id, name, profile.GameData); game.Source = source; profile.GameData.Games.Add(id, game); game.Hidden = XmlUtil.GetBoolFromNode(node[XmlName_Game_Hidden], false); game.Executable = XmlUtil.GetStringFromNode(node[XmlName_Game_Executable], null); game.LastPlayed = XmlUtil.GetIntFromNode(node[XmlName_Game_LastPlayed], 0); if (profileVersion < 1) { string catName; if (XmlUtil.TryGetStringFromNode(node[XmlName_Game_Category], out catName)) { game.AddCategory(profile.GameData.GetCategory(catName)); } if (node.SelectSingleNode(XmlName_Old_Game_Favorite) != null) { game.SetFavorite(true); } } else { XmlNode catListNode = node.SelectSingleNode(XmlName_Game_CategoryList); if (catListNode != null) { XmlNodeList catNodes = catListNode.SelectNodes(XmlName_Game_Category); foreach (XmlNode cNode in catNodes) { string cat; if (XmlUtil.TryGetStringFromNode(cNode, out cat)) { game.AddCategory(profile.GameData.GetCategory(cat)); } } } } } }
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); }
public override AutoCatResult CategorizeGame( GameInfo game ) { 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; 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; }
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); }
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); }
public override AutoCatResult CategorizeGame(GameInfo game) { 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); } int year = db.GetReleaseYear(game.Id); if (year > 0 || IncludeUnknown) { game.AddCategory(games.GetCategory(GetProcessedString(year))); } return(AutoCatResult.Success); }
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); }
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); }
/// <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); }
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); }
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); }
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); }
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); }
private static void AddGameFromNode(XmlNode node, Profile profile) { if (!XmlUtil.TryGetIntFromNode(node[XmlNameGameId], out int id)) { return; } GameListingSource source = XmlUtil.GetEnumFromNode(node[XmlNameGameSource], GameListingSource.Unknown); if (source < GameListingSource.Manual && profile.IgnoreList.Contains(id)) { return; } string name = XmlUtil.GetStringFromNode(node[XmlNameGameName], null); GameInfo game = new GameInfo(id, name, profile.GameData) { Source = source }; profile.GameData.Games.Add(id, game); game.IsHidden = XmlUtil.GetBoolFromNode(node[XmlNameGameHidden], false); game.Executable = XmlUtil.GetStringFromNode(node[XmlNameGameExecutable], null); game.LastPlayed = XmlUtil.GetIntFromNode(node[XmlNameGameLastPlayed], 0); game.HoursPlayed = XmlUtil.GetDoubleFromNode(node[XmlNameGameHoursPlayed], 0); XmlNode catListNode = node.SelectSingleNode(XmlNameGameCategoryList); XmlNodeList catNodes = catListNode?.SelectNodes(XmlNameGameCategory); if (catNodes == null) { return; } foreach (XmlNode cNode in catNodes) { if (XmlUtil.TryGetStringFromNode(cNode, out string cat)) { game.AddCategory(profile.GameData.GetCategory(cat)); } } }
public override AutoCatResult CategorizeGame(GameInfo game) { 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); } 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); }
/// <summary> /// Adds a non-steam game to the gamelist. /// </summary> /// <param name="gameId">ID of the game in the steam config file</param> /// <param name="gameNode">Node for the game in the steam config file</param> /// <param name="launchIds">Dictionary of launch ids (name:launchId)</param> /// <param name="newGames">Number of NEW games that have been added to the list</param> /// <param name="preferSteamCategories">If true, prefers to use the categories from the steam config if there is a conflict. If false, prefers to use the categories from the existing gamelist.</param> /// <returns>True if the game was successfully added</returns> private bool IntegrateShortcut( int gameId, VdfFileNode gameNode, StringDictionary launchIds ) { VdfFileNode nodeName = gameNode.GetNodeAt( new string[] { "appname" }, false ); string gameName = ( nodeName != null ) ? nodeName.NodeString : null; // The ID of the created game must be negative int newId = -( gameId + 1 ); // This should never happen, but just in case if( Games.ContainsKey( newId ) ) { return false; } //Create the new GameInfo GameInfo game = new GameInfo( newId, gameName, this ); Games.Add( newId, game ); // Fill in the LaunchString game.LaunchString = launchIds[gameName]; // Fill in categories VdfFileNode tagsNode = gameNode.GetNodeAt( new string[] { "tags" }, false ); foreach( KeyValuePair<string, VdfFileNode> tag in tagsNode.NodeArray ) { string tagName = tag.Value.NodeString; game.AddCategory( this.GetCategory( tagName ) ); } // Fill in Hidden game.Hidden = false; if( gameNode.ContainsKey( "hidden" ) ) { VdfFileNode hiddenNode = gameNode["hidden"]; game.Hidden = ( hiddenNode.NodeString == "1" || hiddenNode.NodeInt == 1 ); } return true; }
public override AutoCatResult CategorizeGame( GameInfo game ) { 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( 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; }
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); }
/// <summary> /// Adds a non-steam game to the gamelist. /// </summary> /// <param name="gameId">ID of the game in the steam config file</param> /// <param name="gameNode">Node for the game in the steam config file</param> /// <param name="oldShortcuts">List of un-matched non-steam games from the gamelist before the update</param> /// <param name="launchIds">Dictionary of launch ids (name:launchId)</param> /// <param name="newGames">Number of NEW games that have been added to the list</param> /// <param name="preferSteamCategories">If true, prefers to use the categories from the steam config if there is a conflict. If false, prefers to use the categories from the existing gamelist.</param> /// <returns>True if the game was successfully added</returns> private bool IntegrateShortcut( int gameId, VdfFileNode gameNode, List<GameInfo> oldShortcuts, StringDictionary launchIds, ref int newGames, bool preferSteamCategories = true ) { VdfFileNode nodeName = gameNode.GetNodeAt( new string[] { "appname" }, false ); string gameName = ( nodeName != null ) ? nodeName.NodeString : null; // The ID of the created game must be negative int newId = -( gameId + 1 ); // This should never happen, but just in case if( Games.ContainsKey( newId ) ) { return false; } GameInfo game = new GameInfo( newId, gameName ); Games.Add( newId, game ); game.LaunchString = launchIds[gameName]; int oldShortcutId = FindMatchingShortcut( gameId, gameNode, oldShortcuts, launchIds ); bool oldCatSet = ( oldShortcutId != -1 ) && oldShortcuts[oldShortcutId].Categories.Count > 0; if( oldShortcutId == -1 ) newGames++; VdfFileNode tagsNode = gameNode.GetNodeAt( new string[] { "tags" }, false ); bool steamCatSet = ( tagsNode != null && tagsNode.NodeType == ValueType.Array && tagsNode.NodeArray.Count > 0 ); //fill in categories if( steamCatSet && ( preferSteamCategories || !oldCatSet ) ) { // Fill in categories from the Steam shortcut file foreach( KeyValuePair<string, VdfFileNode> tag in tagsNode.NodeArray ) { string tagName = tag.Value.NodeString; game.AddCategory( this.GetCategory( tagName ) ); } } else if( oldShortcutId >= 0 && oldShortcutId < oldShortcuts.Count ) { // Fill in categories from the game list game.SetCategories( oldShortcuts[oldShortcutId].Categories ); } game.Hidden = false; if( gameNode.ContainsKey( "hidden" ) ) { VdfFileNode hiddenNode = gameNode["hidden"]; game.Hidden = ( hiddenNode.NodeString == "1" || hiddenNode.NodeInt == 1 ); } if( oldShortcutId != -1 ) oldShortcuts.RemoveAt( oldShortcutId ); return true; }
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; }
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; }
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; }
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); }
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; }
/// <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); }
private static void AddGameFromXmlNode( XmlNode node, Profile profile, int profileVersion ) { int id; if( XmlUtil.TryGetIntFromNode( node["id"], out id ) ) { if( profile.IgnoreList.Contains( id ) || ( profile.IgnoreDlc && Program.GameDB.IsDlc( id ) ) ) { return; } string name = XmlUtil.GetStringFromNode( node["name"], null ); GameInfo game = new GameInfo( id, name ); profile.GameData.Games.Add( id, game ); game.Hidden = XmlUtil.GetBoolFromNode( node["hidden"], false ); if( profileVersion < 1 ) { string catName; if( XmlUtil.TryGetStringFromNode( node["category"], out catName ) ) { game.AddCategory( profile.GameData.GetCategory( catName ) ); } if( ( node.SelectSingleNode( "favorite" ) != null ) ) { game.AddCategory( profile.GameData.FavoriteCategory ); } } else { XmlNode catListNode = node.SelectSingleNode( "categories" ); if( catListNode != null ) { XmlNodeList catNodes = catListNode.SelectNodes( "category" ); foreach( XmlNode cNode in catNodes ) { string cat; if( XmlUtil.TryGetStringFromNode( cNode, out cat ) ) { game.AddCategory( profile.GameData.GetCategory( cat ) ); } } } } } }
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; }
private static void AddGameFromXmlNode( XmlNode node, Profile profile, int profileVersion ) { int id; if( XmlUtil.TryGetIntFromNode( node[XmlName_Game_Id], out id ) ) { GameListingSource source = XmlUtil.GetEnumFromNode<GameListingSource>( node[XmlName_Game_Source], GameListingSource.Unknown ); if( source < GameListingSource.Manual && profile.IgnoreList.Contains( id ) ) { return; } string name = XmlUtil.GetStringFromNode( node[XmlName_Game_Name], null ); GameInfo game = new GameInfo( id, name, profile.GameData ); game.Source = source; profile.GameData.Games.Add( id, game ); game.Hidden = XmlUtil.GetBoolFromNode( node[XmlName_Game_Hidden], false ); if( profileVersion < 1 ) { string catName; if( XmlUtil.TryGetStringFromNode( node[XmlName_Game_Category], out catName ) ) { game.AddCategory( profile.GameData.GetCategory( catName ) ); } if( ( node.SelectSingleNode( XmlName_Old_Game_Favorite ) != null ) ) { game.SetFavorite( true ); } } else { XmlNode catListNode = node.SelectSingleNode( XmlName_Game_CategoryList ); if( catListNode != null ) { XmlNodeList catNodes = catListNode.SelectNodes( XmlName_Game_Category ); foreach( XmlNode cNode in catNodes ) { string cat; if( XmlUtil.TryGetStringFromNode( cNode, out cat ) ) { game.AddCategory( profile.GameData.GetCategory( cat ) ); } } } } } }
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; }
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); }
public override AutoCatResult CategorizeGame( GameInfo game ) { 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 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; }
public override AutoCatResult CategorizeGame( GameInfo game ) { 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; GameDBEntry dbEntry = db.Games[game.Id]; string genreString = dbEntry.Genre; if( removeOtherGenres && genreCategories != null ) { game.RemoveCategory( genreCategories ); } if( !String.IsNullOrEmpty( genreString ) ) { string[] genreStrings = genreString.Split( new char[] { ',' } ); List<Category> categories = new List<Category>(); for( int i = 0; ( i < maxCategories || maxCategories == 0 ) && i < genreStrings.Length; i++ ) { categories.Add( games.GetCategory( genreStrings[i].Trim() ) ); } game.AddCategory( categories ); } return AutoCatResult.Success; }
public override AutoCatResult CategorizeGame( GameInfo game ) { 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; 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; }
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); }