|
|
@ -1,24 +1,23 @@
|
|
|
|
using QwirkleClassLibrary;
|
|
|
|
using QwirkleClassLibrary;
|
|
|
|
|
|
|
|
using QwirkleConsoleApp;
|
|
|
|
using System.Net.Quic;
|
|
|
|
using System.Net.Quic;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Transactions;
|
|
|
|
using System.Transactions;
|
|
|
|
using static System.Console;
|
|
|
|
using static System.Console;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void AddPlayers(Game game)
|
|
|
|
static void AddPlayers(Game game)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
NotificationClass nc = new NotificationClass();
|
|
|
|
|
|
|
|
game.PlayerAddNotified += nc.NotificationPlayerAdd;
|
|
|
|
|
|
|
|
|
|
|
|
while (game.PlayerList.Count < 4)
|
|
|
|
while (game.PlayerList.Count < 4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write("Enter player tag : ");
|
|
|
|
Write("Enter player tag : ");
|
|
|
|
string? playerTag = ReadLine();
|
|
|
|
string? playerTag = ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (game.AddPlayerInGame(playerTag) == false)
|
|
|
|
game.AddPlayerInGame(playerTag);
|
|
|
|
{
|
|
|
|
|
|
|
|
WriteLine("ERROR : Player already exist or game is running !");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
WriteLine("Player " + playerTag + " added !");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Write("Do you want to add another player ? (y/n) : ");
|
|
|
|
Write("Do you want to add another player ? (y/n) : ");
|
|
|
|
string? answer = ReadLine();
|
|
|
|
string? answer = ReadLine();
|
|
|
@ -38,14 +37,14 @@ static void AddPlayers(Game game)
|
|
|
|
static void ShowTiles(Game game)
|
|
|
|
static void ShowTiles(Game game)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WriteLine("\n --------------------- YOUR TILES ------------------------");
|
|
|
|
WriteLine("\n --------------------- YOUR TILES ------------------------");
|
|
|
|
|
|
|
|
|
|
|
|
var currentPlayer = game.GetPlayingPlayer();
|
|
|
|
var currentPlayer = game.GetPlayingPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentPlayer.Tiles.Count(); i++)
|
|
|
|
for (int i = 0; i < currentPlayer.Tiles.Count(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stringBuilder.Append("[" + (i+1) + "] ");
|
|
|
|
stringBuilder.Append("[" + (i + 1) + "] ");
|
|
|
|
stringBuilder.AppendLine(currentPlayer.Tiles[i].ToString());
|
|
|
|
stringBuilder.AppendLine(currentPlayer.Tiles[i].ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -65,7 +64,7 @@ static void AddTile(Game game)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tile = game.TileOfPlayerWithPos(no - 1);
|
|
|
|
tile = game.TileOfPlayerWithPos(no - 1);
|
|
|
|
|
|
|
|
|
|
|
|
Write("Enter the x of the cell: ");
|
|
|
|
Write("Enter the x of the cell: ");
|
|
|
|
int x = Convert.ToInt32(ReadLine());
|
|
|
|
int x = Convert.ToInt32(ReadLine());
|
|
|
|
Write("Enter the y of the cell : ");
|
|
|
|
Write("Enter the y of the cell : ");
|
|
|
@ -93,14 +92,14 @@ static void SwapTile(Game game)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tilesToSwap = new List<Tile>();
|
|
|
|
var tilesToSwap = new List<Tile>();
|
|
|
|
bool continueSwap = true;
|
|
|
|
bool continueSwap = true;
|
|
|
|
|
|
|
|
|
|
|
|
ShowTiles(game);
|
|
|
|
ShowTiles(game);
|
|
|
|
|
|
|
|
|
|
|
|
while (continueSwap == true)
|
|
|
|
while (continueSwap == true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write("Enter the number of the tile you want to swap : ");
|
|
|
|
Write("Enter the number of the tile you want to swap : ");
|
|
|
|
int no = Convert.ToInt32(ReadLine());
|
|
|
|
int no = Convert.ToInt32(ReadLine());
|
|
|
|
|
|
|
|
|
|
|
|
if (no is < 1 or > 6)
|
|
|
|
if (no is < 1 or > 6)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WriteLine("ERROR : Enter a number between 1 and 6 !");
|
|
|
|
WriteLine("ERROR : Enter a number between 1 and 6 !");
|
|
|
@ -109,23 +108,23 @@ static void SwapTile(Game game)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tilesToSwap.Add(game.TileOfPlayerWithPos(no - 1));
|
|
|
|
tilesToSwap.Add(game.TileOfPlayerWithPos(no - 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Write("Do you want to swap another tile ? (y/n) : ");
|
|
|
|
Write("Do you want to swap another tile ? (y/n) : ");
|
|
|
|
string? answer = ReadLine();
|
|
|
|
string? answer = ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (answer == "n")
|
|
|
|
if (answer == "n")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continueSwap = false;
|
|
|
|
continueSwap = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
game.SwapTiles(game.GetPlayingPlayer(), tilesToSwap);
|
|
|
|
game.SwapTiles(game.GetPlayingPlayer(), tilesToSwap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void MenuSwitch(Game game)
|
|
|
|
static void MenuSwitch(Game game)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int enter = 0;
|
|
|
|
int enter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while (enter != 3)
|
|
|
|
while (enter != 3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ShowBoard(game);
|
|
|
|
ShowBoard(game);
|
|
|
@ -138,7 +137,14 @@ static void MenuSwitch(Game game)
|
|
|
|
WriteLine("[2] Swap your tiles");
|
|
|
|
WriteLine("[2] Swap your tiles");
|
|
|
|
WriteLine("[3] End your turn / Skip your turn");
|
|
|
|
WriteLine("[3] End your turn / Skip your turn");
|
|
|
|
|
|
|
|
|
|
|
|
enter = Convert.ToInt32(ReadLine());
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
enter = Convert.ToInt32(ReadLine());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch {
|
|
|
|
|
|
|
|
WriteLine("ERROR : You must type (1 / 2 / 3). Please retry : ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (enter)
|
|
|
|
switch (enter)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -188,12 +194,14 @@ static void MainMenu(Game game)
|
|
|
|
WriteLine("Game is starting !");
|
|
|
|
WriteLine("Game is starting !");
|
|
|
|
Console.ResetColor();
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NotificationClass nc = new NotificationClass();
|
|
|
|
|
|
|
|
game.NextPlayerNotified += nc.NotificationNextPlayer;
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tagPlayerPlay = game.SetNextPlayer();
|
|
|
|
game.SetNextPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
WriteLine(" --------------------- GAME ! ------------------------");
|
|
|
|
WriteLine(" --------------------- GAME ! ------------------------");
|
|
|
|
WriteLine(tagPlayerPlay + "'s turn !");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
game.DrawTiles(game.GetPlayingPlayer());
|
|
|
|
game.DrawTiles(game.GetPlayingPlayer());
|
|
|
|
MenuSwitch(game);
|
|
|
|
MenuSwitch(game);
|
|
|
@ -209,11 +217,11 @@ static void MainGame()
|
|
|
|
WriteLine(" ===================== WELCOME TO QWIRKLE ! =====================");
|
|
|
|
WriteLine(" ===================== WELCOME TO QWIRKLE ! =====================");
|
|
|
|
WriteLine("Enter the players' nametags (2 to 4 players) : ");
|
|
|
|
WriteLine("Enter the players' nametags (2 to 4 players) : ");
|
|
|
|
Console.ResetColor();
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
|
|
AddPlayers(game);
|
|
|
|
AddPlayers(game);
|
|
|
|
|
|
|
|
|
|
|
|
game.StartGame();
|
|
|
|
game.StartGame();
|
|
|
|
|
|
|
|
|
|
|
|
MainMenu(game);
|
|
|
|
MainMenu(game);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|