예제 #1
0
 public static void WriteKeyValue(string key, object value)
 {
     using (ShellColorizer.SetForeground(ConsoleColor.Black))
     {
         Shell.Write((key + ":").PadRight(16));
     }
     Shell.WriteLine(value);
 }
예제 #2
0
        private static void Main()
        {
            Shell.Initialize(new ShellOptions
            {
                DefaultForegroundColor = ConsoleColor.DarkGray,
                DefaultBackgroundColor = ConsoleColor.Gray,
                PromptColor            = ConsoleColor.Black,
                PromptQuestionColor    = ConsoleColor.Red,
                PromptOptionColor      = ConsoleColor.Magenta,
            });

            Board lastBoard = null;

            do
            {
                Shell.Clear();
                try
                {
                    var options = CreateGameOptions(lastBoard?.Options);
                    if (options == null)
                    {
                        return;
                    }

                    var codemaker   = CreateCodemaker(options, lastBoard?.Codemaker);
                    var codebreaker = CreateCodebreaker(options, lastBoard?.Codebreaker);
                    var board       = new Board(options, codemaker, codebreaker);

                    board.Run();

                    lastBoard = board;
                }
                catch (Exception e)
                {
                    using (ShellColorizer.Set(ConsoleColor.White, ConsoleColor.Red))
                    {
                        Shell.WriteLine($"Error: {e.Message}");
                    }
                    return;
                }
            } while (Shell.PromptBool("Play again?"));
        }