Finished scoring system and started tests

This commit is contained in:
KäseToatz
2024-11-06 21:46:37 +01:00
parent 23ae45ba91
commit af7457a9d9
13 changed files with 265 additions and 50 deletions

View File

@ -7,36 +7,28 @@ namespace Memory.Cmd
{
static void Main()
{
string name = CmdGame.GetPlayerName();
while (true)
{
Game game = new(new ScoreHandler());
Renderer renderer = new(game);
Game game = new(new ScoreHandler(), name);
CmdGame cmdGame = new(game);
while (!game.IsFinished())
{
renderer.Redraw();
cmdGame.Redraw();
Console.Write("Enter card number: ");
try
{
game.ClickCard(game.Cards[int.Parse(Console.ReadLine()!) - 1]);
}
catch (Exception)
{
Console.Write("Invalid card number given.");
Console.ReadLine();
}
catch (Exception) {}
}
Console.Clear();
Console.Write("Game Finished. Do you want to play again? (Y/N): ");
string? answer = Console.ReadLine();
while (answer == null || (!answer.Equals("y", StringComparison.CurrentCultureIgnoreCase) && !answer.Equals("n", StringComparison.CurrentCultureIgnoreCase)))
{
Console.Write("Invalid answer.\nDo you want to play again? (Y/N): ");
answer = Console.ReadLine();
}
if (answer.Equals("n", StringComparison.CurrentCultureIgnoreCase))
cmdGame.WriteScores();
if (!CmdGame.ShouldReplay())
{
break;
}
}
}
}