|
|
|
@ -31,7 +31,10 @@ static void AddPlayers(Game game)
|
|
|
|
|
}
|
|
|
|
|
if (answer == "n" && game.PlayerList.Count < 2)
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must have at least 2 players !");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -62,7 +65,8 @@ static void AddTile(Game game)
|
|
|
|
|
game.PlaceTileNotified += nc.NotificationAddTile;
|
|
|
|
|
|
|
|
|
|
Tile? tile = null;
|
|
|
|
|
Write("Enter the number of the tile you want to place : ");
|
|
|
|
|
|
|
|
|
|
WriteLine("Enter the number of the tile you want to place : ");
|
|
|
|
|
|
|
|
|
|
int no = -1;
|
|
|
|
|
int x = -1;
|
|
|
|
@ -77,39 +81,50 @@ static void AddTile(Game game)
|
|
|
|
|
|
|
|
|
|
if (no is < 1 or > 6)
|
|
|
|
|
{
|
|
|
|
|
Write("ERROR : Enter a number between 1 and 6 ! : ");
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : Enter a number between 1 and 6 ! : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
WriteLine("ERROR : You must type. Please retry : ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tile = game.TileOfPlayerWithPos(no - 1);
|
|
|
|
|
|
|
|
|
|
tile = game.TileOfPlayerWithPos(no - 1);
|
|
|
|
|
Write("Enter the x of the cell: ");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
x = Convert.ToInt32(ReadLine());
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must type. Please retry : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
Write("Enter the y of the cell: ");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
y = Convert.ToInt32(ReadLine());
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must type. Please retry : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("Enter the x of the cell: ");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
x = Convert.ToInt32(ReadLine());
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
WriteLine("ERROR : You must type. Please retry : ");
|
|
|
|
|
}
|
|
|
|
|
Write("Enter the y of the cell: ");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
y = Convert.ToInt32(ReadLine());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must type. Please retry : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
game.PlaceTile(game.GetPlayingPlayer(), tile, x, y);
|
|
|
|
|
game.PlaceTileNotified -= nc.NotificationAddTile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SwapTile(Game game)
|
|
|
|
@ -126,7 +141,10 @@ static void SwapTile(Game game)
|
|
|
|
|
|
|
|
|
|
if (no is < 1 or > 6)
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : Enter a number between 1 and 6 !");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -155,6 +173,8 @@ static void MenuSwitch(Game game)
|
|
|
|
|
|
|
|
|
|
ShowTiles(game);
|
|
|
|
|
|
|
|
|
|
ShowScoreBoard(game);
|
|
|
|
|
|
|
|
|
|
WriteLine("\n --------------------- CHOICES ------------------------");
|
|
|
|
|
|
|
|
|
|
WriteLine("[1] Place your tiles");
|
|
|
|
@ -168,7 +188,10 @@ static void MenuSwitch(Game game)
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must type (1 / 2 / 3). Please retry : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -185,6 +208,7 @@ static void MenuSwitch(Game game)
|
|
|
|
|
WriteLine("Your score on this turn : " + game.GetPlayerScore(game.GetPlayingPlayer(), game.CellsUsed, game.GetBoard()));
|
|
|
|
|
game.EmptyCellUsed();
|
|
|
|
|
game.DrawTiles(game.GetPlayingPlayer());
|
|
|
|
|
game.CheckGameOver(game.GetPlayingPlayer());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -217,6 +241,8 @@ static void ShowBoard(Game game)
|
|
|
|
|
|
|
|
|
|
static void ShowScoreBoard(Game g)
|
|
|
|
|
{
|
|
|
|
|
WriteLine(" --------------------- THE SCORE BOARD : ---------------------");
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (KeyValuePair<Player, int> pair in g.ScoreBoard)
|
|
|
|
|
{
|
|
|
|
@ -235,9 +261,10 @@ static void MainMenu(Game game)
|
|
|
|
|
WriteLine("Game is starting !");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
NotificationClass nc = new NotificationClass();
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
NotificationClass nc = new NotificationClass();
|
|
|
|
|
game.NextPlayerNotified += nc.NotificationNextPlayer;
|
|
|
|
|
game.EndOfGameNotified += nc.NotificationEndOfGame;
|
|
|
|
|
|
|
|
|
@ -248,13 +275,13 @@ static void MainMenu(Game game)
|
|
|
|
|
MenuSwitch(game);
|
|
|
|
|
|
|
|
|
|
game.NextPlayerNotified -= nc.NotificationNextPlayer;
|
|
|
|
|
game.EndOfGameNotified -= nc.NotificationEndOfGame;
|
|
|
|
|
|
|
|
|
|
} while (game.GameRunning);
|
|
|
|
|
|
|
|
|
|
WriteLine(" --------------------- END OF GAME ! ------------------------");
|
|
|
|
|
WriteLine(" --------------------- THE BOARD : --------------------------");
|
|
|
|
|
ShowBoard(game);
|
|
|
|
|
WriteLine(" --------------------- THE SCORE BOARD : ---------------------");
|
|
|
|
|
ShowScoreBoard(game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -269,11 +296,13 @@ static void MainGame()
|
|
|
|
|
|
|
|
|
|
while (enter != 3)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.DarkCyan;
|
|
|
|
|
WriteLine("[1] Create game");
|
|
|
|
|
WriteLine("[2] Show leaderboard");
|
|
|
|
|
WriteLine("[3] Exit");
|
|
|
|
|
Write("Enter your choice : ");
|
|
|
|
|
WriteLine();
|
|
|
|
|
ResetColor();
|
|
|
|
|
WriteLine("Enter your choice : ");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -281,14 +310,20 @@ static void MainGame()
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
WriteLine();
|
|
|
|
|
WriteLine("ERROR : You must type (1 / 2 / 3). Please retry : ");
|
|
|
|
|
ResetColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (enter)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
ForegroundColor = ConsoleColor.DarkYellow;
|
|
|
|
|
WriteLine("Enter minimun 2 player and max 4 player !");
|
|
|
|
|
WriteLine();
|
|
|
|
|
ResetColor();
|
|
|
|
|
Game game = new Game();
|
|
|
|
|
AddPlayers(game);
|
|
|
|
|
game.StartGame();
|
|
|
|
|