Beispiel #1
0
        static void RunSuperHasher9000TM()
        {
            Console.Clear();
            Utils.Bastard.Say("<<< SUPER HASHER 9000(tm) >>>");

            var readLine = new Func <string>(() => {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write("> ");

                Console.ResetColor();

                return(Console.ReadLine());
            });

            var respond = new Action <string>((s) => {
                Utils.Bastard.Say($"{s}");
            });

            var line = "";

            while ((line = readLine()) != null)
            {
                if (line.Length == 0)
                {
                    respond("Type something, dumbass!");
                    continue;
                }

                switch (line[0])
                {
                case '?':
                {
                    var sb  = new StringBuilder();
                    var num = 0;

                    foreach (var hash in StringHasher.GetMissingHashes().OrderBy((k) => $"{k:X8}"))
                    {
                        if ((num % 10) == 0.0)
                        {
                            if (num > 0)
                            {
                                sb.AppendLine();
                            }

                            sb.Append($" - ");
                        }

                        sb.Append($"{hash:X8} ");
                        num++;
                    }

                    sb.AppendLine();

                    if (num > 0)
                    {
                        respond($"{num} unknown hashes:");
                        respond(sb.ToString());
                    }
                    else
                    {
                        respond("You should probably load something first, dumbass.");
                    }
                } continue;

                case '@':
                {
                    var file = line.Substring(1).Replace("\"", "");

                    try
                    {
                        respond("Loading...");

                        var resource = ResourceFactory.Open(file);

                        if (resource != null)
                        {
                            respond("Done.");
                        }
                        else
                        {
                            respond("Fail.");
                        }
                    }
                    catch (Exception)
                    {
                        respond("Nope.");
                    }
                } continue;

                default:
                {
                    var hash = 0;

                    if (line[0] == '$')
                    {
                        try
                        {
                            hash = int.Parse(line.Substring(1), NumberStyles.HexNumber);
                        }
                        catch (Exception)
                        {
                            respond("You're an idiot.");
                            continue;
                        }
                    }
                    else
                    {
                        switch (line)
                        {
                        case "help":
                            respond("I'm afraid I can't do that, Dave.");
                            continue;

                        case "exit":
                            respond("You can check out anytime you like, but you can never leave.");
                            continue;
                        }

                        hash = StringHasher.GetHash(line);
                    }

                    if (StringHasher.CanResolveHash(hash))
                    {
                        respond($"{hash:X8} : '{line}'");
                    }
                    else
                    {
                        if (StringHasher.IsMissingHash(hash))
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.WriteLine("You found a missing hash!");

                            Console.ResetColor();
                        }

                        respond($"{hash:X8} : (unknown)");
                    }
                } continue;
                }
            }
        }