Ejemplo n.º 1
0
 /// <summary>
 /// Writes a line in the box drawn using DrawBox().
 /// </summary>
 /// <param name="str">The string to write into the box.</param>
 /// <param name="timeout">Time to wait between writing each character (default = 10).</param>
 public static void WriteLineToBox(string str, int timeout = 10)
 {
     Console.SetCursorPosition(3, CurLine);
     AenigmaUtils.SlowPrint(str, timeout);
     CurLine++;
     Console.SetCursorPosition(3, CurLine);
 }
Ejemplo n.º 2
0
        public static string HandleLevelUserInput()
        {
            Console.SetCursorPosition(26, 23);

            string tmp = AenigmaUtils.ReadLine();

            Console.SetCursorPosition(26, 23);
            for (int i = 27; i < 45; i++)
            {
                Console.Write("_");
            }

            Console.SetCursorPosition(26, 23);
            return(tmp);
        }
Ejemplo n.º 3
0
        public static void JumpToLevel(AenigmaLevel level)
        {
            // Do some sanity checking on the level.
            if (level == null)
            {
                throw new InvalidLevelException("Cannot load a null level.");
            }

            if (level.ID == Guid.Empty)
            {
                throw new InvalidLevelException("Cannot load a level with an empty GUID.");
            }

            if (string.IsNullOrEmpty(level.Data) || string.IsNullOrWhiteSpace(level.Data))
            {
                throw new InvalidLevelException("Cannot load a level with no level data.");
            }

            CurrentLevel = level;

            // Reset the lives counter to 3.
            NumberOfLives = 3;

            // If this is the starting level, then increment the attempts counter and set the "last played" time.
            if (CurrentLevel.Password != null && CurrentLevel.Password.ToLower() == "start")
            {
                NumberOfAttempts++;
                AenigmaMenuUtils.LastPlayed = DateTime.UtcNow;
            }

            // Draw the level data.
            Console.Clear();
            AenigmaUtils.SlowPrint(level.Data, 0);

            HandleLevel(CurrentLevel);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Run through the boot sequence.
        /// </summary>
        public static void BeginBootSequence()
        {
            ClearBox();

            using (StreamReader sr = new StreamReader("boot/a0.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            AenigmaUtils.ReadLine();

            ClearBox();

            using (StreamReader sr = new StreamReader("boot/a1.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            AenigmaUtils.ReadLine();

            ClearBox();

            using (StreamReader sr = new StreamReader("boot/bios.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }


            Thread.Sleep(2500);

            ClearBox();

            using (StreamReader sr = new StreamReader("boot/bios2.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            Thread.Sleep(2500);

            ClearBox();

            using (StreamReader sr = new StreamReader("boot/floppy.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            Thread.Sleep(500);

            using (StreamReader sr = new StreamReader("boot/floppy2.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 2);
                }
            }

            Thread.Sleep(2000);

            using (StreamReader sr = new StreamReader("boot/floppy3.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 2);
                }
            }

            Thread.Sleep(500);

            using (StreamReader sr = new StreamReader("boot/floppy4.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            Thread.Sleep(100);

            using (StreamReader sr = new StreamReader("boot/floppy5.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            Thread.Sleep(1000);

            using (StreamReader sr = new StreamReader("boot/floppy6.txt"))
            {
                string line;

                PhoneNumber = GetRandomPhoneNumber();
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line.Replace("XXXXX XXXXXX", PhoneNumber), 0);
                }
            }

            Thread.Sleep(2500);

            using (StreamReader sr = new StreamReader("boot/floppy7.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    WriteLineToBox(line, 0);
                }
            }

            Thread.Sleep(500);

            HandleMainMenu();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Run through the main menu.
        /// </summary>
        public static void HandleMainMenu()
        {
            ClearBox();

            WriteLineToBox($"[Connected to Aenigma BBS via {PhoneNumber}]");
            WriteLineToBox("[INFO // https://aenigma.mynameistavis.com]");
            WriteLineToBox("[INFO // Retrieving data from BBS...]");

            int amountLoaded = 0;

            while (amountLoaded < 126)
            {
                if (amountLoaded >= 114)
                {
                    amountLoaded += (126 - amountLoaded);
                }

                WriteStatusMessage($"Downloaded {amountLoaded} / 126 KB.");

                amountLoaded += new Random().Next(5, 12);
                Thread.Sleep(300);
            }

            CurrentUsers = new Random().Next(30, 90);


            using (StreamReader sr = new StreamReader("boot/main_menu.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("{0}"))
                    {
                        line = string.Format(line, LifetimeAttempts,
                                             (LastPlayed != DateTime.MinValue) ? LastPlayed.ToString("HH:mm dd/MM/yy") : "00:00 00/00/00",
                                             CurrentUsers);
                    }

                    line = line.Replace("{color_begin}", "\x1B[0;32m");
                    line = line.Replace("{color_end}", "\x1B[0m");

                    WriteLineToBox(line, 0);
                }
            }

            ClearStatusMessage();

            Console.SetCursorPosition(14, 46);

            AenigmaLevel nextLevel            = null;
            int          LastNumberOfTimeouts = NumberOfTimeouts;

            while (nextLevel == null && LastNumberOfTimeouts == NumberOfTimeouts)
            {
                string password = AenigmaUtils.ReadLine();

                if (password == "sudoritual2216")
                {
                    Environment.Exit(255);
                }

                if (password == "sudoritual2217")
                {
                    BeginBootSequence();
                }

                try
                {
                    nextLevel = AenigmaLevelManager.GetLevelByPassword(password);
                }
                catch (LevelNotFoundException)
                {
                    FailedLoginAttempts++;
                    if (FailedLoginAttempts >= 3)
                    {
                        AenigmaMenuUtils.WriteStatusMessage(
                            "Whatever it is you're doing, please stop it and just type \"start\".");
                    }
                    else
                    {
                        AenigmaMenuUtils.WriteStatusMessage("Invalid password!");
                    }

                    Console.SetCursorPosition(14, 46);
                    for (int i = 0; i < password?.Length; i++)
                    {
                        Console.Write(" ");
                    }
                    Console.SetCursorPosition(14, 46);
                }
            }

            FailedLoginAttempts = 0;
            LifetimeAttempts   += 1;

            if (LastNumberOfTimeouts != NumberOfTimeouts)
            {
                return;
            }

            AenigmaLevelHandler.JumpToLevel(nextLevel);
        }