I tried to add least code as possible but i dont think it worked out in the end. Very nice challenge, looking forward to more like this one.
int level;
string password;
enum Screen { MainMenu, Password, Win }
Screen currentScreen;
void Start() {
ShowMainMenu();
}
void ShowMainMenu() {
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Hello Goat");
Terminal.WriteLine("Learn more about Goats");
Terminal.WriteLine("Breach into these Goat facilities");
Terminal.WriteLine("Learn more about US");
Terminal.WriteLine("Select 1 to hack Local Market");
Terminal.WriteLine("Select 2 to hack City Hospital");
Terminal.WriteLine("Select 3 to hack National Bank");
Terminal.WriteLine("Who will fall first?");
Terminal.WriteLine("Now, choose your target!");
}
void OnUserInput(string input) {
if (input == "menu") {
ShowMainMenu();
}
else if (currentScreen == Screen.MainMenu) {
RunMainMenu(input);
}
else if (currentScreen == Screen.Password) {
PasswordCheck(input, password);
}
else if (currentScreen == Screen.Win) {
if (input == "menu") {
ShowMainMenu();
}
else {
Terminal.WriteLine("Theres nothing more for you here");
}
}
}
void RunMainMenu(string input) {
if (input == "1") {
level = 1;
StartGame();
}
else if (input == "2") {
level = 2;
StartGame();
}
else if (input == "3") {
level = 3;
StartGame();
}
else {
Terminal.WriteLine("Git gut, read instruction");
}
}
void StartGame() {
currentScreen = Screen.Password;
SetPassword();
Terminal.WriteLine("You choose level " + level);
Terminal.WriteLine("To return type Menu");
Terminal.WriteLine("Please enter your password: ");
}
void SetPassword() {
if (level == 1) {
password = "banana";
}
else if (level == 2) {
password = "medicine";
}
else if (level == 3) {
password = "mortgage";
}
}
void PasswordCheck(string input, string password) {
if (input == password) {
currentScreen = Screen.Win;
Terminal.WriteLine("Congratulations, you breached in");
Terminal.WriteLine("Type Menu to return");
}
else if(input == "menu") {
ShowMainMenu();
}
else {
Terminal.WriteLine("Try again or type Menu to return");
currentScreen = Screen.Password;
}
}