Пример #1
0
        public static async Task CreateSchemeAsync(GameServiceClient client)
        {
            var scheme = new Scheme();

            scheme.Name          = ConsoleUtility.GetUserInput("Scheme Name: ");
            scheme.GamePackageId = await GamePackageUtility.SelectGamePackageId(client);

            scheme.AbilityIds.AddRange(await AbilityUtility.SelectAbilityIds(client));
            scheme.HasEpicSide = ConsoleUtility.GetUserInputBool("Has Epic side?");
            scheme.CardRequirements.AddRange(await CardRequirementUtility.GetCardRequirements(client, scheme.GamePackageId, true));
            scheme.TwistRequirements.AddRange(TwistRequirementUtility.GetTwistRequirements(client));

            if (!ConsoleUtility.ShouldContinue($"Creating Scheme: {scheme}"))
            {
                await CreateSchemeAsync(client);

                return;
            }

            var createRequest = new CreateSchemesRequest();

            createRequest.Schemes.Add(scheme);
            var createReply = await client.CreateSchemesAsync(createRequest);

            if (createReply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine($"Failed to create scheme: {createReply.Status.Message}");
            }
            else
            {
                ConsoleUtility.WriteLine($"Scheme '{createReply.Schemes.First().Name}' was created with Id '{createReply.Schemes.First().Id}'");
            }
        }
Пример #2
0
        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);
        }