diff --git a/App/Data/Leaderboard.cs b/App/Data/Leaderboard.cs index 0f88223..e56f492 100644 --- a/App/Data/Leaderboard.cs +++ b/App/Data/Leaderboard.cs @@ -14,6 +14,7 @@ } public static List<(string, int)> ReadScores() { + if (!File.Exists("leaders.txt")) return new List<(string, int)>(); using StreamReader rd = new StreamReader("leaders.txt"); List<(string, int)> scores = new List<(string, int)>(); string? line = null; diff --git a/App/I18n.cs b/App/I18n.cs index d782a3d..7f91682 100644 --- a/App/I18n.cs +++ b/App/I18n.cs @@ -18,6 +18,7 @@ namespace Game { "Cannot read/create the game config file because of an unknown error", "Game rules: press any key to continue...", "Game is over. You gave {0} correct answers out of {1}!", + "Enter your name: ", }}, {"ru-RU", new string[] { "Не указано ни одного варианта ответа на вопрос", @@ -34,6 +35,7 @@ namespace Game { "Произошла неизвестная ошибка при чтении/создании файла настроек", "Правила игры: Вам будет предложено ответить на вопросы. Отвечайте на них правильно и всё будет в шоколаде. Удачи xD! Нажмите любую клавишу, чтобы продолжить", "Игра окончена. Вы ответили правильно на {0} вопросов из {1}!", + "Введите ваше имя: ", }} }; @@ -56,6 +58,7 @@ namespace Game { ERROR_READ_CONFIG_UNKNOWN, RULES, GAME_OVER, + ENTER_NAME, } } } \ No newline at end of file diff --git a/App/Program.cs b/App/Program.cs index 0a368e2..7e4ae98 100644 --- a/App/Program.cs +++ b/App/Program.cs @@ -108,6 +108,10 @@ namespace Game { display.ShowMainGameScreenBase(); display.DrawText(TextDisplay.HAlignment.Center, TextDisplay.VAlignment.Center, display.windowHeight / 4, display.windowWidth / 2 + 1, String.Format(I18n.GetMessage(I18n.Message.GAME_OVER), correntAnswers, questions.Count), 0xffffff, 0x5e61ed); + display.SetCursor(display.windowHeight / 2 + 1, display.windowWidth / 4); + display.WriteColored(I18n.GetMessage(I18n.Message.ENTER_NAME), 0, 0x5e61ed); + Leaderboard.WriteScore(Console.ReadLine(), correntAnswers); + Console.ReadKey(); display.ResetWindow();