better end
This commit is contained in:
parent
8fe7bc212f
commit
1c4ec17476
20
Program.cs
20
Program.cs
@ -61,7 +61,7 @@
|
||||
new Game().Start(board);
|
||||
|
||||
// on demande si les joueurs veulent rejouer
|
||||
new Game().Replay();
|
||||
new Game().Replay(boardSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,10 +77,11 @@
|
||||
/// <summary>
|
||||
/// Méthode pour demander si les joueurs veulent rejouer et pour relancer le jeu si c'est le cas
|
||||
/// </summary>
|
||||
public void Replay()
|
||||
public void Replay(int[] boardSize)
|
||||
{
|
||||
Console.SetCursorPosition(0, _draw.topSpacing + boardSize[0] * 2 + 4);
|
||||
// on demande si l'utilisateur veut rejouer
|
||||
Console.WriteLine("Voulez-vous rejouer ? (o/n)");
|
||||
Console.Write("Voulez-vous rejouer ? (o/n): ");
|
||||
|
||||
// on regarde quelle touche a été pressée
|
||||
switch (Console.ReadKey().Key)
|
||||
@ -90,18 +91,19 @@
|
||||
new Program().SetColor();
|
||||
Console.Clear();
|
||||
new Draw().DrawTitle();
|
||||
int[] boardSize = new Board().BoardSize();
|
||||
boardSize = new Board().BoardSize();
|
||||
Token[,] board = new Token[boardSize[0], boardSize[1]];
|
||||
new Game().Start(board);
|
||||
new Game().Replay();
|
||||
new Game().Replay(boardSize);
|
||||
break;
|
||||
case ConsoleKey.N:
|
||||
// si c'est non on quitte le programme
|
||||
return;
|
||||
default:
|
||||
Console.SetCursorPosition(0, _draw.topSpacing + boardSize[0] * 2 + 5);
|
||||
// sinon on demande de réessayer
|
||||
Console.WriteLine("Entrée invalide");
|
||||
Replay();
|
||||
Console.Write("Entrée invalide");
|
||||
Replay(boardSize);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -238,14 +240,12 @@
|
||||
for (int y = 0; y < board.GetLength(1); y++)
|
||||
{
|
||||
for (int x = 0; x < board.GetLength(0); x++)
|
||||
{
|
||||
if (board[x, y] != 0)
|
||||
{
|
||||
// ajoute 1 si le jeton n'est pas égal à 0
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@
|
||||
// tableau des joueurs
|
||||
Token[] players = {Token.FirstPlayer, Token.SecondPlayer};
|
||||
// boucle qui alterne entre les joueurs 1 et 2
|
||||
foreach (var j in players)
|
||||
foreach (Token j in players)
|
||||
{
|
||||
// boucle qui fait toutes les colonnes
|
||||
for (int y = 0; y < board.GetLength(1); y++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user