add player name prompt and adding to the leaderboard
This commit is contained in:
parent
82ed5fb784
commit
be6c25c35d
@ -14,6 +14,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<(string, int)> ReadScores() {
|
public static List<(string, int)> ReadScores() {
|
||||||
|
if (!File.Exists("leaders.txt")) return new List<(string, int)>();
|
||||||
using StreamReader rd = new StreamReader("leaders.txt");
|
using StreamReader rd = new StreamReader("leaders.txt");
|
||||||
List<(string, int)> scores = new List<(string, int)>();
|
List<(string, int)> scores = new List<(string, int)>();
|
||||||
string? line = null;
|
string? line = null;
|
||||||
|
@ -18,6 +18,7 @@ namespace Game {
|
|||||||
"Cannot read/create the game config file because of an unknown error",
|
"Cannot read/create the game config file because of an unknown error",
|
||||||
"Game rules: <no translation> press any key to continue...",
|
"Game rules: <no translation> press any key to continue...",
|
||||||
"Game is over. You gave {0} correct answers out of {1}!",
|
"Game is over. You gave {0} correct answers out of {1}!",
|
||||||
|
"Enter your name: ",
|
||||||
}},
|
}},
|
||||||
{"ru-RU", new string[] {
|
{"ru-RU", new string[] {
|
||||||
"Не указано ни одного варианта ответа на вопрос",
|
"Не указано ни одного варианта ответа на вопрос",
|
||||||
@ -34,6 +35,7 @@ namespace Game {
|
|||||||
"Произошла неизвестная ошибка при чтении/создании файла настроек",
|
"Произошла неизвестная ошибка при чтении/создании файла настроек",
|
||||||
"Правила игры: Вам будет предложено ответить на вопросы. Отвечайте на них правильно и всё будет в шоколаде. Удачи xD! Нажмите любую клавишу, чтобы продолжить",
|
"Правила игры: Вам будет предложено ответить на вопросы. Отвечайте на них правильно и всё будет в шоколаде. Удачи xD! Нажмите любую клавишу, чтобы продолжить",
|
||||||
"Игра окончена. Вы ответили правильно на {0} вопросов из {1}!",
|
"Игра окончена. Вы ответили правильно на {0} вопросов из {1}!",
|
||||||
|
"Введите ваше имя: ",
|
||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ namespace Game {
|
|||||||
ERROR_READ_CONFIG_UNKNOWN,
|
ERROR_READ_CONFIG_UNKNOWN,
|
||||||
RULES,
|
RULES,
|
||||||
GAME_OVER,
|
GAME_OVER,
|
||||||
|
ENTER_NAME,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,6 +108,10 @@ namespace Game {
|
|||||||
display.ShowMainGameScreenBase();
|
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.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();
|
Console.ReadKey();
|
||||||
|
|
||||||
display.ResetWindow();
|
display.ResetWindow();
|
||||||
|
Loading…
Reference in New Issue
Block a user