private static IEnumerable <CardRequirement> GetCardCountRequirements() { var cardType = ConsoleUtility.GetUserInputRequiredValue("What type of card count is changing?", "Ally", "Adversary", "Mastermind", "Henchman", "Bystander"); var changesBasedOnPlayerCount = ConsoleUtility.GetUserInputBool("Does the card count change based on number of players?"); if (!changesBasedOnPlayerCount) { int additionalSets = ConsoleUtility.GetUserInputInt("Additional sets: "); yield return(cardType switch { "Ally" => new CardRequirement { AdditionalSetCount = additionalSets, CardSetType = CardSetType.CardSetAlly }, "Adversary" => new CardRequirement { AdditionalSetCount = additionalSets, CardSetType = CardSetType.CardSetAdversary }, "Mastermind" => new CardRequirement { AdditionalSetCount = additionalSets, CardSetType = CardSetType.CardSetMastermind }, "Henchman" => new CardRequirement { AdditionalSetCount = additionalSets, CardSetType = CardSetType.CardSetHenchman }, "Bystander" => new CardRequirement { AdditionalSetCount = additionalSets, CardSetType = CardSetType.CardSetBystander }, _ => throw new Exception("Failed to match on cardType") });
internal static IEnumerable <SchemeTwistRequirement> GetSingleTwistRequirement(GameServiceClient client) { var changesBasedOnPlayerCount = ConsoleUtility.GetUserInputBool("Does the twist requirement change based on the number of players? ", null); if (!changesBasedOnPlayerCount) { int twistCount = ConsoleUtility.GetUserInputInt("How many twists? "); yield return(new SchemeTwistRequirement { SchemeTwistCount = twistCount, Allowed = true }); } else { bool schemeAllowedForSinglePlayer = ConsoleUtility.GetUserInputBool($"Is this scheme allowed for a single player? "); if (!schemeAllowedForSinglePlayer) { yield return(new SchemeTwistRequirement { PlayerCount = 1, Allowed = false }); } for (int i = schemeAllowedForSinglePlayer ? 1 : 2; i <= 5; i++) { var playerMessage = i == 1 ? "player" : "players"; int twistCount = ConsoleUtility.GetUserInputInt($"How many twists for {i} {playerMessage}? "); yield return(new SchemeTwistRequirement { PlayerCount = i, SchemeTwistCount = twistCount, Allowed = true }); } } }
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); } } } }