Beispiel #1
0
        public static async Task CreateNeutralAsync(GameServiceClient client)
        {
            var neutral = new Neutral();

            neutral.Name          = ConsoleUtility.GetUserInput("Neutral Name: ");
            neutral.GamePackageId = await GamePackageUtility.SelectGamePackageId(client);

            if (!ConsoleUtility.ShouldContinue($"Creating Neutral: '{neutral.Name}', in gamePackage '{neutral.GamePackageId}'"))
            {
                await CreateNeutralAsync(client);

                return;
            }

            var createRequest = new CreateNeutralsRequest();

            createRequest.Neutrals.Add(neutral);
            var createReply = await client.CreateNeutralsAsync(createRequest);

            if (createReply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine($"Failed to create neutral: {createReply.Status.Message}");
            }
            else
            {
                ConsoleUtility.WriteLine($"Neutral '{createReply.Neutrals.First().Name}' was created with Id '{createReply.Neutrals.First().Id}'");
            }
        }
Beispiel #2
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 #3
0
        public static async Task CreateAdversaryAsync(GameServiceClient client)
        {
            var adversary = new Adversary();

            adversary.Name          = ConsoleUtility.GetUserInput("Adversary Name: ");
            adversary.GamePackageId = await GamePackageUtility.SelectGamePackageId(client);

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

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

                return;
            }

            var createRequest = new CreateAdversariesRequest();

            createRequest.Adversaries.Add(adversary);
            var createReply = await client.CreateAdversariesAsync(createRequest);

            if (createReply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine($"Failed to create adversary: {createReply.Status.Message}");
            }
            else
            {
                ConsoleUtility.WriteLine($"Adversary '{createReply.Adversaries.First().Name}' was created with Id '{createReply.Adversaries.First().Id}'");
            }
        }
Beispiel #4
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}'");
            }
        }
Beispiel #5
0
        public static async Task CreateMastermindAsync(GameServiceClient client)
        {
            var mastermind = new Mastermind();

            mastermind.Name          = ConsoleUtility.GetUserInput("Mastermind Name: ");
            mastermind.GamePackageId = await GamePackageUtility.SelectGamePackageId(client);

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

            if (!ConsoleUtility.ShouldContinue($"Creating Mastermind: {mastermind}"))
            {
                await CreateMastermindAsync(client);

                return;
            }

            var createRequest = new CreateMastermindsRequest();

            createRequest.Masterminds.Add(mastermind);
            var createReply = await client.CreateMastermindsAsync(createRequest);

            if (createReply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine($"Failed to create mastermind: {createReply.Status.Message}");
            }
            else
            {
                ConsoleUtility.WriteLine($"Mastermind '{createReply.Masterminds.First().Name}' was created with Id '{createReply.Masterminds.First().Id}'");
            }
        }
Beispiel #6
0
        public static async ValueTask <int> SelectGamePackageId(GameServiceClient client)
        {
            var gamePackageId = 0;
            IReadOnlyList <GamePackage> gamePackages = null;

            while (gamePackageId == 0)
            {
                var input = ConsoleUtility.GetUserInput("What game package is this entry associated with (? to see listing): ");
                if (input == "?")
                {
                    gamePackages = await DisplayGamePackagesSimpleAsync(client, gamePackages);
                }
                else if (!string.IsNullOrWhiteSpace(input))
                {
                    gamePackages = await GetGamePackagesAsync(client, gamePackages);

                    if (int.TryParse(input, out int id))
                    {
                        gamePackageId = gamePackages.Select(x => x.Id).FirstOrDefault(x => x == id, 0);
                        if (gamePackageId == 0)
                        {
                            ConsoleUtility.WriteLine($"Game Package Id '{input}' was not found");
                        }
                    }
                    else
                    {
                        var matchingGamePackages = gamePackages.Where(x => Regex.IsMatch(x.Name.ToLower(), input.ToLower())).ToList();
                        if (matchingGamePackages.Count == 0)
                        {
                            ConsoleUtility.WriteLine($"Game Package Name '{input}' was not found");
                        }
                        else if (matchingGamePackages.Count != 1)
                        {
                            ConsoleUtility.WriteLine($"Game Package Name '{input}' matched multiple GamePackages ({matchingGamePackages.Select(x => x.Name).Join(", ")})");
                        }
                        else
                        {
                            gamePackageId = matchingGamePackages.First().Id;
                        }
                    }
                }

                if (gamePackageId != 0)
                {
                    var gamePackage = gamePackages.First(x => x.Id == gamePackageId);
                    if (!ConsoleUtility.ShouldContinue($"Adding entry to game package '{gamePackage.Id}: {gamePackage.Name}':"))
                    {
                        gamePackageId = 0;
                    }
                }
            }

            return(gamePackageId);
        }
Beispiel #7
0
        public static async Task <int> SelectTeamId(GameServiceClient client)
        {
            var teamId = 0;
            IReadOnlyList <Team> teams = null;

            while (teamId == 0)
            {
                var input = ConsoleUtility.GetUserInput("What team is this entry associated with (? to see listing): ");
                if (input == "?")
                {
                    teams = await DisplayTeamsSimpleAsync(client, teams);
                }
                else if (!string.IsNullOrWhiteSpace(input))
                {
                    teams = await GetTeamsAsync(client, teams);

                    if (int.TryParse(input, out int id))
                    {
                        teamId = teams.Select(x => x.Id).FirstOrDefault(x => x == id, 0);
                        if (teamId == 0)
                        {
                            ConsoleUtility.WriteLine($"Team Id '{input}' was not found");
                        }
                    }
                    else
                    {
                        var matchingTeams = teams.Where(x => Regex.IsMatch(x.Name.ToLower(), input.ToLower())).ToList();
                        if (matchingTeams.Count == 0)
                        {
                            ConsoleUtility.WriteLine($"Team Name '{input}' was not found");
                        }
                        else if (matchingTeams.Count != 1)
                        {
                            ConsoleUtility.WriteLine($"Team Name '{input}' matched multiple Teams ({matchingTeams.Select(x => x.Name).Join(", ")})");
                        }
                        else
                        {
                            teamId = matchingTeams.First().Id;
                        }
                    }
                }

                if (teamId != 0)
                {
                    var team = teams.First(x => x.Id == teamId);
                    if (!ConsoleUtility.ShouldContinue($"Adding entry to team '{team.Id}: {team.Name}':"))
                    {
                        teamId = 0;
                    }
                }
            }

            return(teamId);
        }
Beispiel #8
0
        public static async Task CreateTeamAsync(GameServiceClient client)
        {
            var teamName  = ConsoleUtility.GetUserInput("Team Name: ");
            var imagePath = ConsoleUtility.GetUserInput("Path to Image (on OneDrive): ");

            var createRequest = new CreateTeamsRequest();

            createRequest.Teams.Add(new Team {
                Name = teamName, ImagePath = imagePath
            });
            createRequest.CreateOptions.Add(CreateOptions.ErrorOnDuplicates);

            var reply = await client.CreateTeamsAsync(createRequest);

            if (reply.Status.Code != 200)
            {
                ConsoleUtility.WriteLine(reply.Status.Message);
            }
            else
            {
                ConsoleUtility.WriteLine($"Team '{reply.Teams.First().Name}' was created with Id '{reply.Teams.First().Id}'");
            }
        }
Beispiel #9
0
        public static async ValueTask <IReadOnlyList <int> > SelectAbilityIds(GameServiceClient client)
        {
            List <int> abilityIds             = new List <int>();
            IReadOnlyList <Ability> abilities = null;

            while (true)
            {
                int abilityId = 0;

                var input = ConsoleUtility.GetUserInput("What ability is this entry associated with (? to see listing, empty to finish): ");

                if (input == "")
                {
                    if (ConsoleUtility.ShouldContinue($"Adding entry to abilities [{abilityIds.Select(x => x.ToString()).Join(", ")}]:"))
                    {
                        return(abilityIds);
                    }

                    return(await SelectAbilityIds(client));
                }

                if (input == "?")
                {
                    abilities = await DisplayAbilitiesAsync(client, abilities);
                }
                else if (!string.IsNullOrWhiteSpace(input))
                {
                    abilities = await GetAbilitiesAsync(client, abilities);

                    if (int.TryParse(input, out int id))
                    {
                        abilityId = abilities.Select(x => x.Id).FirstOrDefault(x => x == id, 0);
                        if (abilityId == 0)
                        {
                            ConsoleUtility.WriteLine($"Ability Id '{input}' was not found");
                        }
                    }
                    else
                    {
                        var matchingAbilities = abilities.Where(x => Regex.IsMatch(x.Name.ToLower(), input.ToLower())).ToList();
                        if (matchingAbilities.Count == 0)
                        {
                            ConsoleUtility.WriteLine($"Ability Name '{input}' was not found");
                        }
                        else if (matchingAbilities.Count != 1)
                        {
                            ConsoleUtility.WriteLine($"Ability Name '{input}' matched multiple Abilities({matchingAbilities.Select(x => x.Name).Join(", ")})");
                        }
                        else
                        {
                            abilityId = matchingAbilities.First().Id;
                        }
                    }
                }

                if (abilityId != 0)
                {
                    var ability = abilities.First(x => x.Id == abilityId);
                    if (ConsoleUtility.ShouldContinue($"Adding entry to ability '{ability.Id}: {ability.Name}':"))
                    {
                        abilityIds.Add(abilityId);
                    }
                }
            }
        }
Beispiel #10
0
        internal static async ValueTask <IEnumerable <ClassInfo> > SelectClassIds(GameServiceClient client)
        {
            List <ClassInfo>      classInfos = new List <ClassInfo>();
            IReadOnlyList <Class> classes    = null;

            while (true)
            {
                int classId = 0;

                int classCount = classInfos.Sum(x => x.Count);

                var input = ConsoleUtility.GetUserInput("What class is this entry associated with (? to see listing, empty to finish): ");

                if (input == "")
                {
                    if (classCount < 14)
                    {
                        ConsoleUtility.WriteLine($"Must supply a class count of at least 14 (currently {classCount})");
                    }
                    else
                    {
                        if (ConsoleUtility.ShouldContinue($"Adding entry to classes [{classInfos.Select(x => x.ToString()).Join(", ")}] (Total {classCount}):"))
                        {
                            return(classInfos);
                        }

                        return(await SelectClassIds(client));
                    }
                }

                if (input == "?")
                {
                    classes = await DisplayClassesAsync(client, classes);
                }
                else if (!string.IsNullOrWhiteSpace(input))
                {
                    classes = await GetClassesAsync(client, classes);

                    if (int.TryParse(input, out int id))
                    {
                        classId = classes.Select(x => x.Id).FirstOrDefault(x => x == id, 0);
                        if (classId == 0)
                        {
                            ConsoleUtility.WriteLine($"Class Id '{input}' was not found");
                        }
                    }
                    else
                    {
                        var matchingClasses = classes.Where(x => Regex.IsMatch(x.Name.ToLower(), input.ToLower())).ToList();
                        if (matchingClasses.Count == 0)
                        {
                            ConsoleUtility.WriteLine($"Class Name '{input}' was not found");
                        }
                        else if (matchingClasses.Count != 1)
                        {
                            ConsoleUtility.WriteLine($"Class Name '{input}' matched multiple Classes ({matchingClasses.Select(x => x.Name).Join(", ")})");
                        }
                        else
                        {
                            classId = matchingClasses.First().Id;
                        }
                    }
                }

                if (classId != 0)
                {
                    var @class    = classes.First(x => x.Id == classId);
                    var cardCount = ConsoleUtility.GetUserInputInt("Enter number of cards for this class: ");

                    var classInfo = new ClassInfo {
                        ClassId = @class.Id, Count = cardCount
                    };

                    if (ConsoleUtility.ShouldContinue($"Adding entry to clases '{@class.Id}: {@class.Name}', count '{classInfo.Count}':"))
                    {
                        classInfos.Add(classInfo);
                    }
                }
            }
        }