static void Main(string[] args) { //1. Welcome the user //2. Menu actions: ////a. create character //// a1. name, vocation //// b. choose character //// c. remove character //// d. enter the game //3. The story //4. The game //5. If win/lose return the total result of the fight ActionMenuService actionService = new ActionMenuService(); Console.WriteLine("Hello. Welcome to The Game..."); Console.WriteLine("Please choose what do you want to do: "); //A method that initializes all the menu elements that will be created and used later actionService = Init(actionService); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}"); } //when we want to choose the action we can use readkey which reads only 1 sign entered from the user. var operation = Console.ReadKey(); CharacterService charCreation = new CharacterService(actionService); switch (operation.KeyChar) { case '1': charCreation.AddNewCharacter(); break; case '2': break; case '3': string characterToRemove = CharacterService.RemoveCharacter(); break; case '4': break; default: Console.WriteLine("Chosen wrong action. Please try again!"); break; } }
public void AddNewCharacter() { var menuId; do { Console.Clear(); var addNewItemMenu = actionService.GetMenuActionsByMenuName("charCreation"); Console.WriteLine("Please choose from the following: "); for (int i = 0; i < addNewItemMenu.Count; i++) { Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}"); } ConsoleKey operation = Console.ReadKey(true).Key; } while (!(menuId == 49 || menuId == 50 || menuId == 51)); if (menuId == 51) { return; } ProceedWithCharacterCreation(menuId); }