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}'"); } }
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}'"); } }
public static async Task DisplaySchemesAsync(GameServiceClient client, IReadOnlyList <int> schemeIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { foreach (var scheme in await GetSchemesAsync(client, schemeIds, name, nameMatchStyle)) { ConsoleUtility.WriteLine($"{scheme}"); } }
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}'"); } }
public static async Task DisplayMastermindsAsync(GameServiceClient client, IReadOnlyList <int> mastermindIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { foreach (var mastermind in await GetMastermindsAsync(client, mastermindIds, name, nameMatchStyle)) { ConsoleUtility.WriteLine($"{mastermind}"); } }
public static async Task DisplayGamePackageAsync(GameServiceClient client, IReadOnlyList <int> packageIds, string name) { var packagesRequest = new GetGamePackagesRequest(); if (packageIds != null && packageIds.Count() != 0) { packagesRequest.GamePackageIds.AddRange(packageIds); } else if (!string.IsNullOrWhiteSpace(name)) { packagesRequest.Name = name; } else { throw new ArgumentException("Either 'packageId' or 'name' must be non-null"); } packagesRequest.Fields.AddRange(new[] { GamePackageField.Id, GamePackageField.Name, GamePackageField.PackageType, GamePackageField.BaseMap }); var packagesReply = await client.GetGamePackagesAsync(packagesRequest); if (packagesReply.Status.Code != 200) { ConsoleUtility.WriteLine(packagesReply.Status.Message); } foreach (var gamePackage in packagesReply.Packages) { ConsoleUtility.WriteLine(gamePackage.ToString()); } }
public static async Task DisplayHenchmenAsync(GameServiceClient client, IReadOnlyList <int> henchmanIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { foreach (var henchman in await GetHenchmenAsync(client, henchmanIds, name, nameMatchStyle)) { ConsoleUtility.WriteLine($"{henchman}"); } }
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}'"); } }
public static async Task DisplayNeutralsAsync(GameServiceClient client, IReadOnlyList <int> neutralIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { foreach (var neutral in await GetNeutralsAsync(client, neutralIds, name, nameMatchStyle)) { ConsoleUtility.WriteLine($"{neutral}"); } }
public static async Task DisplayAlliesAsync(GameServiceClient client, IReadOnlyList <int> allyIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { foreach (var ally in await GetAlliesAsync(client, allyIds, name, nameMatchStyle)) { ConsoleUtility.WriteLine($"{ally}"); } }
public static async Task CreateItemAsync(GameServiceClient client, string[] args) { if (args.FirstOrDefault() == "t") { await CreateTeamAsync(client); } else if (args.FirstOrDefault() == "h") { await CreateHenchmanAsync(client); } else if (args.FirstOrDefault() == "n") { await CreateNeutralAsync(client); } else if (args.FirstOrDefault() == "al") { await CreateAllyAsync(client); } else if (args.FirstOrDefault() == "ad") { await CreateAdversaryAsync(client); } else if (args.FirstOrDefault() == "m") { await MastermindUtility.CreateMastermindAsync(client); } else if (args.FirstOrDefault() == "s") { await SchemeUtility.CreateSchemeAsync(client); } else { ConsoleUtility.WriteLine("Must supply the type of item you want to create. (t|h|ad|n|al|m|s)"); } }
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}'"); } }
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); }
public static async ValueTask <IReadOnlyList <GamePackage> > DisplayGamePackagesSimpleAsync(GameServiceClient client, IReadOnlyList <GamePackage> gamePackages) { gamePackages = await GetGamePackagesAsync(client, gamePackages); foreach (var gamePackage in gamePackages) { ConsoleUtility.WriteLine($"{gamePackage.Id}: {gamePackage.Name}"); } return(gamePackages); }
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); }
public static async ValueTask <IReadOnlyList <Team> > DisplayTeamsSimpleAsync(GameServiceClient client, IReadOnlyList <Team> teams) { teams = await GetTeamsAsync(client, teams); foreach (var team in teams) { ConsoleUtility.WriteLine($"{team.Id}: {team.Name}"); } return(teams); }
public static async ValueTask <IReadOnlyList <Class> > DisplayClassesAsync(GameServiceClient client, IReadOnlyList <Class> classes) { classes = await GetClassesAsync(client, classes); foreach (var ability in classes) { ConsoleUtility.WriteLine($"{ability.Id}: {ability.Name}"); } return(classes); }
public static async ValueTask <IReadOnlyList <Ability> > DisplayAbilitiesAsync(GameServiceClient client, IReadOnlyList <Ability> abilities) { abilities = await GetAbilitiesAsync(client, abilities); foreach (var ability in abilities) { ConsoleUtility.WriteLine($"{ability.Id}: {ability.Name}"); } return(abilities); }
public static async Task DisplayAllGamePackagesAsync(GameServiceClient client) { var request = new GetGamePackagesRequest(); request.Fields.AddRange(new[] { GamePackageField.Id }); var reply = await client.GetGamePackagesAsync(request); if (reply.Status.Code != 200) { ConsoleUtility.WriteLine(reply.Status.Message); } foreach (var package in reply.Packages) { await DisplayGamePackageAsync(client, new[] { package.Id }, null); } }
public static async Task DisplayAbilitiesAsync(GameServiceClient client, IReadOnlyList <int> ids, string name) { var abilitiesRequest = new GetAbilitiesRequest(); if (ids != null && ids.Count() != 0) { abilitiesRequest.AbilityIds.AddRange(ids); } else if (name != null) { abilitiesRequest.Name = name; } abilitiesRequest.AbilityFields.AddRange(new[] { AbilityField.Id, AbilityField.Name, AbilityField.Description, AbilityField.GamePackageName }); var abilities = await client.GetAbilitiesAsync(abilitiesRequest); foreach (var ability in abilities.Abilities) { ConsoleUtility.WriteLine($"{ability.GamePackage.Name} - {ability.Name} - {ability.Description}"); } }
public static async Task DisplayTeamsAsync(GameServiceClient client, IReadOnlyList <int> teamIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { var request = new GetTeamsRequest(); if (teamIds != null && teamIds.Count() != 0) { request.TeamIds.AddRange(teamIds); } else if (!string.IsNullOrWhiteSpace(name)) { request.Name = name; } request.NameMatchStyle = nameMatchStyle; var teams = await client.GetTeamsAsync(request); foreach (var team in teams.Teams) { ConsoleUtility.WriteLine($"{team}"); } }
public static async Task DisplayClassesAsync(GameServiceClient client, IReadOnlyList <int> classIds = null, string name = null, NameMatchStyle nameMatchStyle = NameMatchStyle.MixedCase) { var request = new GetClassesRequest(); if (classIds != null && classIds.Count() != 0) { request.ClassIds.AddRange(classIds); } else if (!string.IsNullOrWhiteSpace(name)) { request.Name = name; } request.NameMatchStyle = nameMatchStyle; var classes = await client.GetClassesAsync(request); foreach (var @class in classes.Classes) { ConsoleUtility.WriteLine($"{@class}"); } }
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}'"); } }
public static async Task DisplayAllAbilitiesAsync(GameServiceClient client) { var request = new GetGamePackagesRequest(); request.Fields.AddRange(new[] { GamePackageField.Id, GamePackageField.Name, GamePackageField.PackageType, GamePackageField.BaseMap }); var reply = await client.GetGamePackagesAsync(request); foreach (var gameData in reply.Packages.OrderBy(x => x.BaseMap).ThenBy(x => x.PackageType).ThenBy(x => x.Name)) { var abilitiesRequest = new GetAbilitiesRequest { GamePackageId = gameData.Id }; abilitiesRequest.AbilityFields.AddRange(new[] { AbilityField.Id, AbilityField.Name, AbilityField.GamePackageName }); var abilities = await client.GetAbilitiesAsync(abilitiesRequest); foreach (var ability in abilities.Abilities) { ConsoleUtility.WriteLine($"{ability.GamePackage.Name} - {ability.Name}"); } } }
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); } } } }
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); } } } }