private bool ApplyCooptimusData(Game game, CooperativeGame dbGame) { var gameUpdated = false; if (game.FeatureIds == null) { game.FeatureIds = new List <Guid> { }; gameUpdated = true; } var modesBasic = GetBasicModes(dbGame); var modesDetailed = GetDetailedModes(dbGame); foreach (var coopName in modesBasic.Concat(modesDetailed)) { // Should make it faster than trying to create the same // features a lot of times if (!featuresDictionary.ContainsKey(coopName)) { featuresDictionary.Add(coopName, PlayniteApi.Database.Features.Add(coopName)); } if (game.FeatureIds.AddMissing(featuresDictionary[coopName].Id)) { gameUpdated = true; } } if (settings.Settings.AddLinkOnImport) { if (game.Links == null) { game.Links = new ObservableCollection <Link> { new Link { Name = "Co-Optimus", Url = dbGame.Url } }; gameUpdated = true; } else if (!game.Links.Any(x => x.Url == dbGame.Url)) { var linksCopy = new ObservableCollection <Link>(game.Links) { new Link { Name = "Co-Optimus", Url = dbGame.Url } }; game.Links = linksCopy; gameUpdated = true; } } if (gameUpdated) { PlayniteApi.Database.Games.Update(game); } return(gameUpdated); }
private List <string> GetDetailedModes(CooperativeGame dbGame) { var modesDetailed = new List <string>(); if (!settings.Settings.ImportDetailedModes) { return(modesDetailed); } if (settings.Settings.ImportDetailedModeLocal && dbGame.ModesDetailed.LocalCoop != "Not Supported") { var modeName = GetDetailedModeFormatedStr($"Local Co-Op: {dbGame.ModesDetailed.LocalCoop}"); modesDetailed.Add(modeName); } if (settings.Settings.ImportDetailedModeOnline && dbGame.ModesDetailed.OnlineCoop != "Not Supported") { var modeName = GetDetailedModeFormatedStr($"Online Co-Op: {dbGame.ModesDetailed.OnlineCoop}"); modesDetailed.Add(modeName); } if (settings.Settings.ImportDetailedModeCombo && dbGame.ModesDetailed.ComboCoop != "Not Supported") { var modeName = GetDetailedModeFormatedStr($"Combo Co-Op: {dbGame.ModesDetailed.ComboCoop}"); modesDetailed.Add(modeName); } if (settings.Settings.ImportDetailedModeLan && dbGame.ModesDetailed.LanPlay != "Not Supported") { var modeName = GetDetailedModeFormatedStr($"LAN Play: {dbGame.ModesDetailed.LanPlay}"); modesDetailed.Add(modeName); } if (settings.Settings.ImportDetailedModeExtras && dbGame.ModesDetailed.Extras?.Count < 0) { foreach (var extraInfo in dbGame.ModesDetailed.Extras) { var modeName = GetDetailedModeFormatedStr($"Co-Op Extras: {extraInfo}"); modesDetailed.Add(modeName); } } return(modesDetailed); }
private List <string> GetBasicModes(CooperativeGame dbGame) { var modesBasic = new List <string>(); if (!settings.Settings.ImportBasicModes) { return(modesBasic); } foreach (var mode in dbGame.Modes) { if (settings.Settings.AddPrefix) { modesBasic.Add(settings.Settings.FeaturesPrefix + mode); } else { modesBasic.Add(mode); } } return(modesBasic); }