using System.Reflection.PortableExecutable; namespace ICE5 { internal class Program { static void Main(string[] args) { // declare all our variables that we will reuse here // Change the Console colours Console.BackgroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.White; //declares and instantiates a random object (random number seed) Random d10 = new Random(); // Character's Name string CharacterName = "Unknown"; // declared integer array named PrimaryAttributes // allocted memory (instantiated) for an int array of length 6 // created parallel arrays for Primary Attributes int[] PrimaryAttributes = new int[6]; string[] PrimaryAttributeNames = ["Agility", "Strength", "Vigour", "Perception", "Intellect", "Will"]; string[] PrimaryAttributesShort = ["AGL", "STR", "VGR", "PER", "INT", "WIL"]; // created parallel arrays for Secondary Attributes int[] SecondaryAttributes = new int[3]; string[] SecondaryAttributeNames = ["Awareness", "Toughness", "Resolve"]; // Migrated to Multi-Dimensional Array named Career Templates int[][] CareerTemplates = [ [35, 35, 30, 30, 25, 25], // Army [30, 35, 30, 25, 35, 25], // Psion [35, 30, 30, 35, 25, 25], // Rogue [25, 25, 30, 30, 35, 35], // Telepath [30, 35, 25, 30, 35, 25], // Tinker ]; string[] Careers = ["Army", "Psion", "Rogue", "Telepath", "Tinker"]; // outer while loop ConsoleKey NextKey = ConsoleKey.None; while (NextKey != ConsoleKey.Q && NextKey != ConsoleKey.Escape) { // Career Variables string Career = "Unknown"; int CareerChoice = 0; bool HasChosenCareer = false; Console.Clear(); // Change the Console Title Bar Console.Title = "Character Sheet"; // Prompt for CharacterName Console.Write("Enter Character Name: "); CharacterName = Console.ReadLine(); Console.WriteLine("Select your Career: "); Console.Write("Enter Character Name: "); CharacterName = Console.ReadLine(); Console.WriteLine("Select your Career:"); for (int careerIndex = 0; careerIndex < Careers.Length; careerIndex++) { Console.Write($"{careerIndex + 1}. {Careers[careerIndex]} ("); for (int attributeIndex = 0; attributeIndex < PrimaryAttributesShort.Length; attributeIndex++) { Console.Write($"{PrimaryAttributesShort[attributeIndex]}: {CareerTemplates[careerIndex][attributeIndex]}"); if (attributeIndex < PrimaryAttributesShort.Length - 1) Console.Write(", "); } Console.WriteLine(")"); } Console.WriteLine("6. Random"); // Inner while loop bool IsValid = false; while (!IsValid) { Console.Write("Enter 1 to 6: "); IsValid = int.TryParse(Console.ReadLine(), out CareerChoice); if (!IsValid) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Invalid Entry. Try again."); Console.ForegroundColor = ConsoleColor.White; } } // this statement replaces the previous switch / case if (CareerChoice > 0 && CareerChoice < 6) { Career = Careers[CareerChoice - 1]; UseCareerTemplate(CareerTemplates[CareerChoice - 1]); HasChosenCareer = true; } else if (CareerChoice == 6) { Career = "Random"; for (int index = 0; index < 6; index++) { PrimaryAttributes[index] = Roll5d10(); } HasChosenCareer = true; } else { Console.WriteLine("You entered an incorrect choice. Please run the program again."); HasChosenCareer = false; Console.WriteLine("Press Q or ESC to exit."); NextKey = Console.ReadKey(true).Key; continue; } if (HasChosenCareer == true) { // Migrating from previous code SecondaryAttributes[0] = PrimaryAttributes[0] + PrimaryAttributes[3]; SecondaryAttributes[1] = PrimaryAttributes[1] + PrimaryAttributes[2]; SecondaryAttributes[2] = PrimaryAttributes[4] + PrimaryAttributes[5]; // output the character sheet Console.Clear(); Console.WriteLine("------------------------------------------------------"); Console.WriteLine($"Character Name: {CharacterName}"); Console.WriteLine("------------------------------------------------------"); Console.WriteLine($"Career : {Career}"); Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Primary Attributes"); Console.WriteLine("------------------------------------------------------"); PrintAttribute(PrimaryAttributeNames, PrimaryAttributes); Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Secondary Attributes"); Console.WriteLine("------------------------------------------------------"); PrintAttribute(SecondaryAttributeNames, SecondaryAttributes); Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Press Q or ESC to Exit"); NextKey = Console.ReadKey(true).Key; Console.Clear(); continue; } } // local function int Roll5d10() { int total = 0; for (int die = 0; die < 5; die++) { total += d10.Next(1, 11); } return total; } void UseCareerTemplate(int[] career) { for (int index = 0; index < 6; index++) { PrimaryAttributes[index] = career[index]; } } void PrintAttribute(string[] AttributeNames, int[] AttributeValues) { for (int index = 0; index < AttributeNames.Length; index++) { Console.WriteLine($"{AttributeNames[index],-10} : {AttributeValues[index]}"); } } } } }