public void Menu() { bool validInput = true; while (validInput) { Console.Clear(); string text = @" *************************************** * Aloha and welcome to your Adventure * *************************************** Please make a choice 1. New Game 2. Command List 3. Are you a little dumb? L2P and RTFM 4. Exit"; Formatting(text); Console.Write("> ", Color.DeepPink); string input = Console.ReadLine(); switch (input) { case "1": CreatePlayer(); break; case "2": RulesAndCommands.Commands(); break; case "3": RulesAndCommands.Rules(); break; case "4": Console.Clear(); Console.WriteLine("I knew you didn't have it in you. Peasant."); ExitGame(); Console.ReadLine(); Environment.Exit(0); break; default: Console.Clear(); Console.WriteLine("Wrong input! Please chose a valid number!"); Console.ReadLine(); break; } } }
public void Play() { bool playing = true; string input; Item item = null; Console.WriteLine(); RoomDetails(); // THE GAME LOOP do { if (currentRoom.TutorialFinish) { Console.WriteLine("\nWell played... almost! This was just the tutorial stupid."); Console.Write($"Do you want to continue with the REAL game {player.Name}? "); input = Console.ReadLine().ToUpper(); switch (input) { case "Y": case "YES": currentRoom.TutorialFinish = false; break; default: ExitGame(); break; } System.Console.WriteLine("\nWelcome, to the real world " + player.Name + ". "); } Console.WriteLine(); Console.Write("> ", Color.DeepPink); input = Console.ReadLine().ToUpper(); Console.Clear(); Console.WriteLine(); List <string> inputs = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (string.IsNullOrEmpty(input)) { Console.WriteLine("Write something, dude!"); } else { switch (inputs[0]) { case "EXIT": { ExitGame(); break; } case "MOVE": case "GO": { if (inputs.Count <= 1) { Console.WriteLine($"That's not a valid command {player.Name}! Use DIRECTIONS: NORTH, EAST, SOUTH, WEST."); } else if (allDirections.Contains(inputs[1])) { MoveTo(inputs[1]); RoomDetails(); } break; } // NORTH, SOUTH etc... case "NORTH": case "EAST": case "SOUTH": case "WEST": { if (inputs.Count == 1) { MoveTo(input); RoomDetails(); } else { Console.WriteLine($"That's not a valid command {player.Name}! Use DIRECTIONS: NORTH, EAST, SOUTH, WEST."); } break; } case "LOOK": case "EXAMINE": { if (inputs.Count == 1) { RoomDetails(); } else { inputs.RemoveAt(0); string fullName = string.Join(" ", inputs); LookAt(fullName); } break; } case "GET": case "PICKUP": { if (inputs.Count > 1) { inputs.RemoveAt(0); string fullItemName = string.Join(" ", inputs); if (currentRoom.GetItems() != null) { item = currentRoom.Pickup(fullItemName); if (item != null) { currentRoom.RemoveItem(item); player.AddItem(item); Console.Write("You picked up a "); PrintItem(item); Console.WriteLine(". "); } else { Console.WriteLine("No. You can't pick that up, whatever that is... "); } } } else { Console.WriteLine("Get / Pick up what?"); } break; } case "DROP": { item = DropItems(item, inputs); break; } case "USE": { if (inputs.Count > 1) { UseItem(inputs); } else { Console.WriteLine("Use what?"); } break; } case "COMMANDS": { RulesAndCommands.Commands(); break; } case "RULES": { RulesAndCommands.Rules(); break; } case "INVENTORY": { Console.WriteLine("You look through your pockets. "); Console.WriteLine("INVENTORY"); Console.WriteLine("-----------------------------------"); if (player.GetItems().Count == 0) { Console.WriteLine("Empty"); } else { foreach (Item i in player.GetItems()) { PrintItem(i); Console.WriteLine(); } } Console.WriteLine("-----------------------------------"); break; } default: Console.WriteLine("Commands mudafada. Do you type it!? Type RULES or COMMANDS for help, you noob. "); break; } } } while (playing); }