public void MainMenu() { while (true) { Console.Clear(); Console.SetCursorPosition(125, 4); Console.Write($"Days to simulate: {totalDaysToSim}"); Console.SetCursorPosition(125, 5); Console.Write($"Ticks per second: {ticksPerSecond}"); Console.SetCursorPosition(1, 32); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Just started up the 'game' for the first time? "); Console.SetCursorPosition(1, 33); Console.ResetColor(); Console.Write("Make sure the connectionstring in the HamsterDbContext.cs-file is right for your SQL Server on your computer"); string title = @" ██░ ██ ▄▄▄ ███▄ ▄███▓ ██████▄▄▄█████▓█████ ██▀███ ██▓███ ▄▄▄ ██▀███ ▄▄▄ ▓█████▄ ██▓ ██████▓█████ ▓██░ ██▒████▄ ▓██▒▀█▀ ██▒██ ▒▓ ██▒ ▓▓█ ▀▓██ ▒ ██▒ ▓██░ ██▒████▄ ▓██ ▒ ██▒████▄ ▒██▀ ██▓██▒██ ▒▓█ ▀ ▒██▀▀██▒██ ▀█▄ ▓██ ▓██░ ▓██▄ ▒ ▓██░ ▒▒███ ▓██ ░▄█ ▒ ▓██░ ██▓▒██ ▀█▄ ▓██ ░▄█ ▒██ ▀█▄ ░██ █▒██░ ▓██▄ ▒███ ░▓█ ░██░██▄▄▄▄██▒██ ▒██ ▒ ██░ ▓██▓ ░▒▓█ ▄▒██▀▀█▄ ▒██▄█▓▒ ░██▄▄▄▄██▒██▀▀█▄ ░██▄▄▄▄██░▓█▄ ░██░ ▒ ██▒▓█ ▄ ░▓█▒░██▓▓█ ▓██▒██▒ ░██▒██████▒▒ ▒██▒ ░░▒████░██▓ ▒██▒ ▒██▒ ░ ░▓█ ▓██░██▓ ▒██▒▓█ ▓██░▒████▓░██▒██████▒░▒████▒ ▒ ░░▒░▒▒▒ ▓▒█░ ▒░ ░ ▒ ▒▓▒ ▒ ░ ▒ ░░ ░░ ▒░ ░ ▒▓ ░▒▓░ ▒▓▒░ ░ ░▒▒ ▓▒█░ ▒▓ ░▒▓░▒▒ ▓▒█░▒▒▓ ▒░▓ ▒ ▒▓▒ ▒ ░░ ▒░ ░ ▒ ░▒░ ░ ▒ ▒▒ ░ ░ ░ ░▒ ░ ░ ░ ░ ░ ░ ░▒ ░ ▒░ ░▒ ░ ▒ ▒▒ ░ ░▒ ░ ▒░ ▒ ▒▒ ░░ ▒ ▒ ▒ ░ ░▒ ░ ░░ ░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ (Use the arrow keys to cycle through options and press enter to select an option.)"; string[] options = new string[] { "Start Simulation", "Change Values (default are already set)", "Look at specific simulation", "Exit the program" }; UserMenu mainMenu = new UserMenu(title, options, 0, 3); int selectedIndex = mainMenu.Run(); switch (selectedIndex) { case 0: Console.WriteLine("\n\nLoading.."); StartSimulation(); break; case 1: totalDaysToSim = ChooseDaysToSimulate(); ticksPerSecond = ChooseTicksPerSecond(); break; case 2: Console.WriteLine("\n\nLoading.."); SimulationMenu(); break; case 3: Console.WriteLine("\n\nShutting the program off.."); Thread.Sleep(1000); Environment.Exit(0); break; } } }
private int ChooseTicksPerSecond() { while (true) { Console.Clear(); Console.SetCursorPosition(1, 22); Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("NOTE: 5 (20+ times), 6 (30+ times) & 7 (40+ times) ticks per second has been tested a total of almost 100 times with"); Console.SetCursorPosition(1, 23); Console.Write("a range of 2-8 days runtime on both my laptop and desktop. In 4 of them, all being 7 ticks per second (142 ms/tick),"); Console.SetCursorPosition(1, 24); Console.Write("did it crash mid-simulation. This due to the timer going to fast and a update going a little too slow."); Console.SetCursorPosition(1, 25); Console.Write("It ran fine on 7 tick simulations directly after those failed runs aswell. Thus, there should not be any"); Console.SetCursorPosition(1, 26); Console.Write("issues running the simulation on up to 7 ticks per second but there is a small change a hiccup can occur."); Console.ResetColor(); string title = @" _______ _ _ _ ___ |__ __(_) | | | |__ \ | | _ ___| | _____ _ __ ___ _ __ ___ ___ ___ ___ _ __ __| | ) | | | | |/ __| |/ / __| | '_ \ / _ | '__| / __|/ _ \/ __/ _ \| '_ \ / _` | / / | | | | (__| <\__ \ | |_) | __| | \__ | __| (_| (_) | | | | (_| ||_| |_| |_|\___|_|\_|___/ | .__/ \___|_| |___/\___|\___\___/|_| |_|\__,_|(_) | | |_| (Use the arrow keys to cycle through options and press enter to select an option.)"; string[] options = new string[] { " Default (2) ", " (1) ", " (2) ", " (3) ", "Recommended (4)", " (5) ", " (6) ", " (7) " }; UserMenu ticksPerSecondMenu = new UserMenu(title, options, 10, 25); int selectedIndex = ticksPerSecondMenu.Run(); switch (selectedIndex) { case 0: case 2: return(2); case 1: case 3: case 4: case 5: case 6: case 7: return(selectedIndex); } } }
private int ChooseDaysToSimulate() { while (true) { Console.Clear(); string title = @" _____ _ _ _ _ ___ | __ \ | | (_) | | | | |__ \ | | | | __ _ _ _ ___ | |_ ___ ___ _ _ __ ___ _ _| | __ _| |_ ___ ) | | | | |/ _` | | | / __| | __/ _ \ / __| | '_ ` _ \| | | | |/ _` | __/ _ \/ / | |__| | (_| | |_| \__ \ | || (_) | \__ | | | | | | | |_| | | (_| | || __|_| |_____/ \__,_|\__, |___/ \__\___/ |___|_|_| |_| |_|\__,_|_|\__,_|\__\___(_) __/ | |___/ (Use the arrow keys to cycle through options and press enter to select an option.)"; string[] options = new string[] { " Default (2) ", " (1) ", " (2) ", " (3) ", " (4) ", " (5) ", " (6) ", " (7) ", " (8) ", " (9) ", "Random (10->30)" }; UserMenu daysToSimMenu = new UserMenu(title, options, 10, 25); int selectedIndex = daysToSimMenu.Run(); switch (selectedIndex) { case 0: case 2: return(2); case 1: case 3: case 4: case 5: case 6: case 7: case 8: case 9: return(selectedIndex); case 10: return(random.Next(10, 31)); } } }
private void SimulationMenu() { while (true) { string title = @" _____ _ _ _ _ _ / ____| | (_) | | | | (_) | | | |__ ___ ___ ___ ___ __ _ ___ _ _ __ ___ _ _| | __ _| |_ _ ___ _ __ | | | '_ \ / _ \ / _ \/ __|/ _ \ / _` | / __| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ \ | |____| | | | (_) | (_) \__ | __/ | (_| | \__ | | | | | | | |_| | | (_| | |_| | (_) | | | | \_____|_| |_|\___/ \___/|___/\___| \__,_| |___|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_| (Use the arrow keys to cycle through options and press enter to select an option.)"; List <string> allSimulations = new List <string>(); allSimulations = simulationInfo.GetAllSimulations(); allSimulations.Insert(0, "[Go back to previous menu]"); string[] options = allSimulations.ToArray(); Console.Clear(); UserMenu simulationMenu = new UserMenu(title, options, 10, 20); currentSimulationInfoId = simulationMenu.Run(); if (currentSimulationInfoId == 0) { break; } else { string currentSimString = options[currentSimulationInfoId]; string[] splitString = currentSimString.Split('-'); string currentSimSplitString = splitString[0]; string[] splitStringAgain = currentSimSplitString.Split(" "); currentSimulationInfoId = int.Parse(splitStringAgain[1]); SimulationInfoMenu(currentSimulationInfoId); } } }
private void SimulationInfoMenu(int currentSimulationId) { while (true) { Console.Clear(); string title = @" _____ _ _ _ | __ \ | | | | | | | | | | __ _ _ _ ___ _ __ | |_ ___ | |_ __ _| | | | | |/ _` | | | | / _ \| '__| | __/ _ \| __/ _` | | | |__| | (_| | |_| | | (_) | | | || (_) | || (_| | | |_____/ \__,_|\__, | \___/|_| \__\___/ \__\__,_|_| __/ | |___/ (Use the arrow keys to cycle through options and press enter to select an option.)"; List <string> allDays = simulationInfo.GetAllDays(currentSimulationId); allDays.Insert(0, "[Go back to previous menu]"); allDays.Add("Show total for all days"); string[] options = allDays.ToArray(); UserMenu simulationMenu = new UserMenu(title, options, 10, 20); int currentThingToCheck = simulationMenu.Run(); if (currentThingToCheck == 0) { break; } else if (currentThingToCheck == options.Length - 1) { PrintSimulationSummary(options.Length - 2, currentSimulationId); } else { PrintDaySimulationSummary(currentThingToCheck, currentSimulationId); } } }