38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Memory.Data;
|
|
using Memory.Logic;
|
|
|
|
namespace Memory.Cmd
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main()
|
|
{
|
|
string name = CmdGame.GetPlayerName();
|
|
while (true)
|
|
{
|
|
Game game = new(new ScoreHandler(), name, 10);
|
|
CmdGame cmdGame = new(game);
|
|
// While the game isn't finished ask for a card index then attempt to click the card
|
|
while (!game.IsFinished())
|
|
{
|
|
cmdGame.Redraw();
|
|
Console.Write("Enter card number: ");
|
|
try
|
|
{
|
|
game.ClickCard(game.Cards[int.Parse(Console.ReadLine()!) - 1]);
|
|
}
|
|
catch (Exception) {}
|
|
}
|
|
Console.Clear();
|
|
cmdGame.WriteScores();
|
|
// Ask if the player wants to play again, if not break out of the loop and the program is finished
|
|
if (!CmdGame.ShouldReplay())
|
|
{
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|