Finished my DnD-Inspired Terminal Hacker

This is a reupload because, through adding the code directly in, I violated the Guidelines due to profanity used in the code. Still wanting to share what I have done, I have taken the profanity out.

Finally finished my first “game.” Took a little longer than expected to get it working the way I wanted to due to the extra screens and back-tracks I added. As the title implies, it is heavily themed off of DnD. I even combed through the Monster Manual and Mordenkainen’s Tomb of Foes to find suitable monsters (passwords) for you to guess!
HINT: Except for one monster in the Apprentice section, in the game of DnD, you could actually fight those monsters at that level. So an Apprentice could fight the monsters (passwords) hinted at, the Hero could fight their monsters, and the Paragon could fight their monsters.

There are two easter eggs in it.
For the first one, I’ll give you a hint; In the game of DnD, what is even more powerful than the gods?
The second Easter Egg was put it solely for my close friend, and without looking at the code, I don’t believe anyone could guess it.

Check it out and tell me what you think!

Here is the code so that you may view/copy/paste/edit as you want!

using UnityEngine;

public class Hacker : MonoBehaviour
{
    //Game Config. Data
    string[] level1Passwords = { "bandit", "goblin", "orc", "lich", "gnoll" };
    string[] level2Passwords = { "elemental", "nightmare", "vampire", "homonculus", "werewolf" };
    string[] level3Passwords = { "leviathan", "demogorgon", "eidolon", "remorhaz", "zuggtomy" };

    //Game State
    int level;
    enum Screen { Intro, Rules1, Rules2, MainMenu, EasterEgg, Chosen, Password, Win };
    Screen currentScreen;
    string password;

    // Use this for initialization
    void Start() //Auto-forwards to ShowIntro
    {
        ShowIntro();
    }

    void OnUserInput(string input) //Master inputs (tavern, restart, quit, help) & "Enter to continue" commands for each page that contains it.
    {
        if (input == "tavern" || Input.anyKeyDown & currentScreen == Screen.Win)
        {
            ShowMainMenu("Welcome back!");
        }
        else if (input == "restart")
        {
            ShowIntro();
        }
        else if (input == "quit")
        {
            Application.Quit();
        }
        else if (input == "help" || Input.anyKeyDown & currentScreen == Screen.Intro)
        {
            ShowRules1();
        }
        else if (Input.anyKeyDown & currentScreen == Screen.Rules1)
        {
            ShowRules2();
        }
        else if (Input.anyKeyDown & currentScreen == Screen.Rules2)
        {
            ShowMainMenu("What type of Adventurer are you?");
        }
        else if (Input.anyKeyDown & currentScreen == Screen.EasterEgg)
        {
            ShowMainMenu("Please choose a body to inhabit");
        }
        else if (Input.anyKeyDown & currentScreen == Screen.Chosen)
        {
            AskForPassword();
        }
        else if (currentScreen == Screen.MainMenu)
        {
            RunMainMenu(input);
        }
        else if (currentScreen == Screen.Password)
        {
            CheckPassword(input);
        }
    }

    void ShowIntro()
    {
        currentScreen = Screen.Intro;
        Terminal.ClearScreen();
        Terminal.WriteLine("Welcome to The Tavern");
        Terminal.WriteLine("Your objective is to prove your salt");
        Terminal.WriteLine("as an adventurer by guessing the");
        Terminal.WriteLine("correct monster based on the scrambled");
        Terminal.WriteLine("letters provided.");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("Press (Enter/Return) to continue...");
    } //set screen to Intro & writes intro to terminal

    void ShowRules1()
    {
        Terminal.ClearScreen();
        currentScreen = Screen.Rules1;
        Terminal.WriteLine("Rules/Help");
        Terminal.WriteLine("_Be sure to type ALL entries in lower-");
        Terminal.WriteLine("cases while playing");
        Terminal.WriteLine("_Type -tavern- at any time to return");
        Terminal.WriteLine("to the tavern and choose a different");
        Terminal.WriteLine("adventuring level");
        Terminal.WriteLine("_Type -restart- at any time to reset");
        Terminal.WriteLine("the entire game");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("Press (Enter/Return) to continue...");

    } //Set screen to Rules1 & writes pg 1 of rules to terminal

    void ShowRules2()
    {
        Terminal.ClearScreen();
        currentScreen = Screen.Rules2;
        Terminal.WriteLine("Rules/Help (pg. 2)");
        Terminal.WriteLine("_Type -help- at any time to return to");
        Terminal.WriteLine("this screen");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("");
        Terminal.WriteLine("Press (Enter/Return) to continue...");
    } //Set screen to Rules2 & writes pg 2 of rules to terminal

    void ShowMainMenu(string greeting) //Set screen to MainMenu & writes main menu to terminal
    {
        Terminal.ClearScreen();
        currentScreen = Screen.MainMenu;
        level = 0;
        Terminal.WriteLine(greeting);
        Terminal.WriteLine("1) Apprentice: You are new to these");
        Terminal.WriteLine("lands and the monsters of it.");
        Terminal.WriteLine("2) Hero: You have travelled the");
        Terminal.WriteLine("world and faced its' dangers. ");
        Terminal.WriteLine("3) Paragon: You are a true master of");
        Terminal.WriteLine("killing terrible foes. ");
        Terminal.WriteLine("Typing -tavern- at any time will allow");
        Terminal.WriteLine("you to return to this menu");
        Terminal.WriteLine("Enter your selection:");
    }

    void RunMainMenu(string input) //Command for selecting level & forwards to RunChosen or RunEasterEgg depending on level chosen
    {
        bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
        if (isValidLevelNumber)
        {
            level = int.Parse(input);
            RunChosen();
        }
        else if (input == "dm" || input == "dungeon master")
        {
            level = 4;
            RunEasterEgg();
        }
        else if (input == "poncho")
        {
            level = 5;
            RunEasterEgg();
        }
        else
        {
            ShowMainMenu("Please make a valid selection");
        }
    }

    void RunEasterEgg()
    {
        currentScreen = Screen.EasterEgg;
        Terminal.ClearScreen();
        switch (level)
        {
            case 4:
                Terminal.WriteLine("Please select a lesser body to");
                Terminal.WriteLine("inhabit, oh Great One");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Press (Enter/Return) to return to the");
                Terminal.WriteLine("tavern and pick from the lowly vessels");
                Terminal.WriteLine("offered within");
                break;
            case 5:
                Terminal.WriteLine("Alex, if you are wanting to play");
                Terminal.WriteLine("Warhammer, next time just ask...");
                Terminal.WriteLine("");
                Terminal.WriteLine("Also, Mazdamundi is a lil baby");
                Terminal.WriteLine("");
                Terminal.WriteLine("Press (Enter/Return) to return to the");
                Terminal.WriteLine("tavern");
                break;
        }             
    } //Shows Easter Egg Screen 

    void RunChosen() //Shows Chosen Screen & Forwards to AskForPassword
    {
        currentScreen = Screen.Chosen;
        Terminal.ClearScreen();
        switch (level)
        {
            case 1:
                Terminal.WriteLine("You chose Apprentice.");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Prepare for adventure!");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Press (Enter/Return) to continue...");
                break;
            case 2:
                Terminal.ClearScreen();
                Terminal.WriteLine("You chose Hero.");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Prepare for adventure!");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Press (Enter/Return) to continue...");
                break;
            case 3:
                Terminal.ClearScreen();
                Terminal.WriteLine("You chose Paragon.");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Prepare for failure!");
                Terminal.WriteLine("");
                Terminal.WriteLine("");
                Terminal.WriteLine("Press (Enter/Return) to continue...");
                break;
            default:
                Debug.LogError("Invalid level number");
                break;
        }
    }

    void AskForPassword() //Sets Password Screen & Calls SetRandomPassword 
    {
        currentScreen = Screen.Password;
        Terminal.ClearScreen();
        SetRandomPassword();
        Terminal.WriteLine("hint: " + password.Anagram());
        Terminal.WriteLine("What is the monster?");
    }

    void SetRandomPassword() //Command for setting random passwords
    {
        switch (level)
        {
            case 1:
                password = level1Passwords[Random.Range(0, level1Passwords.Length)];
                break;
            case 2:
                password = level2Passwords[Random.Range(0, level2Passwords.Length)];
                break;
            case 3:
                password = level3Passwords[Random.Range(0, level3Passwords.Length)];
                break;
            default:
                Debug.LogError("Invalid level number");
                break;
        }
    }

    void CheckPassword(string input) //Command for checking if password is correct or not & forwarding to DisplayWinScreen if correct
    {
        if (input == password)
        {
            DisplayWinScreen();
        }
        else
        {
            Terminal.WriteLine("Sorry, wrong monster!");
            AskForPassword();
        }
    }

    void DisplayWinScreen() //Command for showing "Win Screen"
    {
        currentScreen = Screen.Win;
        Terminal.ClearScreen();
        ShowLevelReward();
    }

    void ShowLevelReward() //Final "Win Screen" for each level
    {
        switch (level)
        {
            case 1:
                Terminal.WriteLine("Have a drink on the house!");
                Terminal.WriteLine(@"
         . .
       .. . *.
- -_ _-__-0oOo
 _-_ -__ -||||)
    ______||||______
~~~~~~~~~~`""""'
"
                );
                //                  12345678901234567890123456789012345678
                Terminal.WriteLine("Press (Enter/Return) to continue");
                break;
            case 2:
                Terminal.WriteLine("You truly are a distinguished");
                Terminal.WriteLine("individual!");
                Terminal.WriteLine(@"
   _a' /(   <.  WAKEN  .>   )\ `e_
~~ _}\ \(  _  )  THE  (  _  )/ /{_ ~~
      \(,_(,)' DRAGONS `(.)_.)/
     ._>, _>,	        .<_ .<_.
"
                );
                Terminal.WriteLine("Press (Enter/Return) to continue");
                break;
            case 3:
                Terminal.WriteLine("You know no cruel gods of fate;");
                Terminal.WriteLine("only fortune smiles upon you!");
                Terminal.WriteLine(@"
 ____   ___   ____    ____
|  _ \ ( _ ) |  _ \  /\' .\   ____
| | | |/ _ \/\ | | |/: \___\ / .  /\
| |_| | (_>  < |_| |\' / . //____/..\
|____/ \___/\/____/  \/___/ \'  '\  /
                             \'__'\/
"
                );
                Terminal.WriteLine("Press (Enter/Return) to continue");
                break;
            default:
                Debug.LogError("Invalid Level Reached");
                break;

        }
    }

}


2 Likes

So creative. The ascii art is a nice touch. :slight_smile:

Privacy & Terms