Fixed all requirements

This commit is contained in:
KäseToatz
2024-11-07 01:52:51 +01:00
parent af7457a9d9
commit 0121584708
20 changed files with 171 additions and 69 deletions

View File

@ -6,10 +6,10 @@ namespace Memory.Cmd
{
private readonly Game game = game;
private static string FormatNumber(int number)
private string FormatNumber(int number)
{
string num = "";
int padding = Game.DECKSIZE.ToString().Length - number.ToString().Length;
int padding = game.DeckSize.ToString().Length - number.ToString().Length;
for (int i = 0; i < padding; i++)
{
num += '0';
@ -18,22 +18,22 @@ namespace Memory.Cmd
return num;
}
private static void DrawCard(Card card, int index, int column, int row)
private void DrawCard(Card card, int index, int column, int row)
{
string num = FormatNumber(card.ID);
string cardNr = FormatNumber(index);
int cardWidth = Game.DECKSIZE.ToString().Length + 4;
for (int i = 0; i < Game.GRIDSIZE; i++)
int cardWidth = game.DeckSize.ToString().Length + 4;
for (int i = 0; i < game.GridSize; i++)
{
Console.CursorLeft += (cardWidth + 1) * column;
Console.CursorTop = i + ((Game.GRIDSIZE + 1) * row) + 1;
Console.CursorTop = i + (game.GridSize + 1) * row;
for (int j = 0; j < cardWidth; j++)
{
if (i == 0)
{
Console.Write('#');
}
else if (i == Game.GRIDSIZE - 1)
else if (i == game.GridSize - 1)
{
if (j > 1 && j < cardWidth - 2)
{
@ -48,7 +48,7 @@ namespace Memory.Cmd
{
Console.Write('#');
}
else if (i == Game.GRIDSIZE / 2 && j > 1 && j < cardWidth - 2)
else if (i == game.GridSize / 2 && j > 1 && j < cardWidth - 2)
{
if (card.Selected())
{
@ -71,7 +71,6 @@ namespace Memory.Cmd
public void Redraw()
{
Console.Clear();
Console.WriteLine($"Score: {game.Scoring.Points}");
for (int i = 0; i < game.Cards.Count; i++)
{
Card card = game.Cards[i];
@ -83,9 +82,9 @@ namespace Memory.Cmd
}
else
{
Console.ForegroundColor= ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Red;
}
DrawCard(game.Cards[i], i + 1, i % Game.GRIDSIZE, i / Game.GRIDSIZE);
DrawCard(game.Cards[i], i + 1, i % game.GridSize, i / game.GridSize);
Console.ForegroundColor = ConsoleColor.White;
}
}

View File

@ -10,7 +10,7 @@ namespace Memory.Cmd
string name = CmdGame.GetPlayerName();
while (true)
{
Game game = new(new ScoreHandler(), name);
Game game = new(new ScoreHandler(), name, 10);
CmdGame cmdGame = new(game);
while (!game.IsFinished())
{