Added gui version and basic scorehandler
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Memory.Data\Memory.Data.csproj" />
|
||||
<ProjectReference Include="..\Memory.Logic\Memory.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Memory.Logic;
|
||||
using Memory.Data;
|
||||
using Memory.Logic;
|
||||
|
||||
namespace Memory.Cmd
|
||||
{
|
||||
@ -6,24 +7,37 @@ namespace Memory.Cmd
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Game game = new();
|
||||
Renderer renderer = new(game);
|
||||
while (!game.IsFinished())
|
||||
while (true)
|
||||
{
|
||||
renderer.Render();
|
||||
Console.Write("Enter card number: ");
|
||||
try
|
||||
Game game = new(new ScoreHandler());
|
||||
Renderer renderer = new(game);
|
||||
while (!game.IsFinished())
|
||||
{
|
||||
game.ClickCard(game.Cards[int.Parse(Console.ReadLine()!) - 1]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Invalid card number given.");
|
||||
Console.ReadLine();
|
||||
renderer.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();
|
||||
}
|
||||
}
|
||||
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))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
renderer.Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Memory.Logic;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Memory.Cmd
|
||||
{
|
||||
@ -52,14 +50,14 @@ namespace Memory.Cmd
|
||||
}
|
||||
else if (i == Game.GRIDSIZE / 2 && j > 1 && j < cardWidth - 2)
|
||||
{
|
||||
if (card.Selected())
|
||||
{
|
||||
//if (card.Selected())
|
||||
//{
|
||||
Console.Write(num[j - 2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write('*');
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Console.Write('*');
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -70,8 +68,9 @@ namespace Memory.Cmd
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
public void Redraw()
|
||||
{
|
||||
Console.Clear();
|
||||
for (int i = 0; i < game.Cards.Count; i++)
|
||||
{
|
||||
Card card = game.Cards[i];
|
||||
|
Reference in New Issue
Block a user