private static async ValueTask <IReadOnlyList <Scheme> > CreateSchemes(GameServiceClient client, IReadOnlyList <Ability> abilities, IReadOnlyList <GamePackage> packages) { ConsoleUtility.WriteLine("Creating schemes"); List <Scheme> result = (await SchemeUtility.GetSchemesAsync(client, null)).ToList(); // if (result.Any()) // return result; foreach (var file in Directory.EnumerateFiles(@"C:\Users\Ryan\SkyDrive\code\LegendaryGameStarter\LegendaryGameModel2\GameSets", s_fileMask)) { var doc = XDocument.Load(file); var name = doc.Element("Set").Attribute("Name").Value; var activeGamePackage = packages.FirstOrDefault(x => x.Name == name); if (activeGamePackage == null) { ConsoleUtility.WriteLine($"Failed to find matching game package for {file}"); } foreach (var schemeElement in doc.Element("Set").Element("Cards").Elements("Card").Where(x => x?.Attribute("Area").Value == "Scheme")) { var request = new CreateSchemesRequest(); request.CreateOptions.Add(CreateOptions.ErrorOnDuplicates); var scheme = new Scheme(); scheme.Name = schemeElement.Attribute("Name").Value; scheme.GamePackageId = activeGamePackage.Id; scheme.AbilityIds.AddRange(GetMatchingItems(schemeElement.Attribute("Abilities")?.Value, name => abilities.First(x => x.Name == name)).Select(x => x.Id)); scheme.CardRequirements.AddRange(GetCardRequirements(client, schemeElement, activeGamePackage.Id)); scheme.HasEpicSide = (schemeElement.Attribute("HasEpicSide")?.Value.ToLower() ?? "false") == "true"; scheme.TwistRequirements.AddRange(GetTwistRequirements(client, schemeElement)); ConsoleUtility.WriteLine(scheme.ToString()); request.Schemes.Add(scheme); var reply = await client.CreateSchemesAsync(request); if (reply.Status.Code != 200) { ConsoleUtility.WriteLine($"Failed to create '{scheme.Name}': {reply.Status.Message}"); } result.AddRange(reply.Schemes); } ConsoleUtility.WriteLine($"Completed: {name}"); } return(result); }
public override async Task <CreateSchemesReply> CreateSchemes(CreateSchemesRequest request, ServerCallContext context) { return(await SchemeUtility.CreateSchemesAsync(request, context)); }