/// <summary> /// Auto-create some scavenger hunt entries for a standalone game DB. Makes a list for entries that have a wikipedia tag, /// and then entries for all styles in the first TagParser style that have IsGameElement set to true. /// </summary> /// <param name="allPlaces">the list of OSM elements to search</param> /// <returns>the list of scavenger hunt entries</returns> public static List <ScavengerHuntStandalone> GetScavengerHunts(List <DbTables.Place> allPlaces) { //TODO: This is going to need updated for the new TagParser rules. testing at the minimum var results = new List <ScavengerHuntStandalone>(); var wikiList = allPlaces.Where(a => a.Tags.Any(t => t.Key == "wikipedia") && TagParser.GetPlaceName(a.Tags) != "").Select(a => TagParser.GetPlaceName(a.Tags)).Distinct().ToList(); //Create automatic scavenger hunt entries. Dictionary <string, List <string> > scavengerHunts = new Dictionary <string, List <string> >(); //NOTE: //If i run this by elementID, i get everything unique but several entries get duplicated becaues they're in multiple pieces. //If I run this by name, the lists are much shorter but visiting one distinct location might count for all of them (This is a bigger concern with very large areas or retail establishment) //So I'm going to run this by name for the player's sake. scavengerHunts.Add("Wikipedia Places", wikiList); Log.WriteLog(wikiList.Count() + " Wikipedia-linked items found for scavenger hunt."); //fill in gameElement lists. foreach (var gameElementTags in TagParser.allStyleGroups.First().Value.Where(s => s.Value.IsGameElement)) { var foundElements = allPlaces.Where(a => TagParser.MatchOnTags(gameElementTags.Value, a.Tags) && !string.IsNullOrWhiteSpace(TagParser.GetPlaceName(a.Tags))).Select(a => TagParser.GetPlaceName(a.Tags)).Distinct().ToList(); scavengerHunts.Add(gameElementTags.Value.Name, foundElements); Log.WriteLog(foundElements.Count() + " " + gameElementTags.Value.Name + " items found for scavenger hunt."); } foreach (var hunt in scavengerHunts) { foreach (var item in hunt.Value) { results.Add(new ScavengerHuntStandalone() { listName = hunt.Key, description = item, playerHasVisited = false }); } } return(results); }