Esempio n. 1
0
        public bool MatchesCollection(LibraryCollection collection)
        {
            //Check this item's console is in the collection
            if (collection.GameConsoleIds != null && collection.GameConsoleIds.Count > 0 && !collection.GameConsoleIds.Contains(GameConsoleId ?? 0))
            {
                return(false);
            }
            //Check that this item supports the number of players
            //Treat "Unknown" player count as one player
            int evalMinPlayers = MinPlayers > 0 ? MinPlayers : 1;
            int evalMaxPlayers = MaxPlayers > 0 ? MaxPlayers : 1;

            if (collection.MinPlayers > evalMaxPlayers)
            {
                return(false);
            }
            //Check that this item has the required play time
            if (collection.MinHours > 0 && collection.MinHours > HoursPlayed)
            {
                return(false);
            }
            //Check that this item has all tags in the collection
            if (collection.Tags != null && collection.Tags.Count > 0)
            {
                foreach (string tag in collection.Tags)
                {
                    if (!Tags.Contains(tag))
                    {
                        return(false);
                    }
                }
            }
            //Check that this item matches the search string
            if (collection.SearchString != null)
            {
                string filterString = collection.SearchString.ToLower();
                if (!string.IsNullOrWhiteSpace(filterString) && !Title.ToLower().Contains(filterString) && !TagsSimple.ToLower().Contains(filterString))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        private static List <LibraryCollection> GetAllCollections()
        {
            //TODO: Get collections from a file
            List <LibraryCollection> customCollections    = new List <LibraryCollection>();
            List <LibraryCollection> generatedCollections = new List <LibraryCollection>();
            //Add recently played collection
            LibraryCollection recentCollection = new LibraryCollection("Recently Played");

            recentCollection.SortField = "LastPlayed";
            recentCollection.MinHours  = 0.001;
            generatedCollections.Add(recentCollection);
            //Generate auto-collections for each console
            foreach (GameConsole console in AllGameConsoles)
            {
                generatedCollections.Add(new LibraryCollection(console));
            }
            //Return both collection lists merged
            generatedCollections.AddRange(customCollections);
            return(generatedCollections);
        }
Esempio n. 3
0
 public void CreateNewSearch()
 {
     SearchCollection = new LibraryCollection("Search");
 }