Beispiel #1
0
        public static async Task CreateHenchmanAsync(GameServiceClient client)
        {
            var henchman = new Henchman();

            henchman.Name          = ConsoleUtility.GetUserInput("Henchman Name: ");
            henchman.GamePackageId = await GamePackageUtility.SelectGamePackageId(client);

            henchman.AbilityIds.AddRange(await AbilityUtility.SelectAbilityIds(client));

            if (!ConsoleUtility.ShouldContinue($"Creating Henchman: '{henchman.Name}', in gamePackage '{henchman.GamePackageId}' with abilities [{henchman.AbilityIds.Select(x => x.ToString()).Join(", ")}]"))
            {
                await CreateHenchmanAsync(client);

                return;
            }

            var createRequest = new CreateHenchmenRequest();

            createRequest.Henchmen.Add(henchman);
            var createReply = await client.CreateHenchmenAsync(createRequest);

            if (createReply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine($"Failed to create henchman: {createReply.Status.Message}");
            }
            else
            {
                ConsoleUtility.WriteLine($"Henchman '{createReply.Henchmen.First().Name}' was created with Id '{createReply.Henchmen.First().Id}'");
            }
        }
Beispiel #2
0
        private static async ValueTask <IReadOnlyList <Henchman> > CreateHenchmen(GameServiceClient client, IReadOnlyList <GamePackage> packages, IReadOnlyList <Ability> abilities)
        {
            ConsoleUtility.WriteLine("Creating henchmen");
            List <Henchman> result = (await HenchmanUtility.GetHenchmenAsync(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 henchmanElement in doc.Element("Set").Element("Cards").Elements("Card").Where(x => x?.Attribute("Area").Value == "Henchman"))
                {
                    var request = new CreateHenchmenRequest();
                    request.CreateOptions.Add(CreateOptions.ErrorOnDuplicates);

                    var henchman = new Henchman();
                    henchman.Name          = henchmanElement.Attribute("Name").Value;
                    henchman.GamePackageId = activeGamePackage.Id;
                    henchman.AbilityIds.AddRange(GetMatchingItems(henchmanElement.Attribute("Abilities")?.Value, name => abilities.First(x => x.Name == name)).Select(x => x.Id));

                    request.Henchmen.Add(henchman);

                    var reply = await client.CreateHenchmenAsync(request);

                    if (reply.Status.Code != 200)
                    {
                        ConsoleUtility.WriteLine($"Failed to create '{henchman.Name}': {reply.Status.Message}");
                    }

                    result.AddRange(reply.Henchmen);
                }

                ConsoleUtility.WriteLine($"Completed: {name}");
            }

            return(result);
        }