|
|
|
@ -1,24 +1,26 @@
|
|
|
|
|
using QwirkleClassLibrary;
|
|
|
|
|
using QwirkleConsoleApp;
|
|
|
|
|
using System.Net.Quic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Transactions;
|
|
|
|
|
using static System.Console;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void AddPlayers(Game game)
|
|
|
|
|
{
|
|
|
|
|
NotificationClass nc = new NotificationClass();
|
|
|
|
|
|
|
|
|
|
while (game.PlayerList.Count < 4)
|
|
|
|
|
{
|
|
|
|
|
Write("Enter player tag : ");
|
|
|
|
|
string? playerTag = ReadLine();
|
|
|
|
|
|
|
|
|
|
if (game.AddPlayerInGame(playerTag) == false)
|
|
|
|
|
{
|
|
|
|
|
WriteLine("ERROR : Player already exist or game is running !");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WriteLine("Player " + playerTag + " added !");
|
|
|
|
|
}
|
|
|
|
|
game.AddPlayerInGame(playerTag);
|
|
|
|
|
|
|
|
|
|
game.PlayerAddNotified -= nc.NotificationMessagePlayer;
|
|
|
|
|
|
|
|
|
|
game.PlayerAddNotified += nc.NotificationMessagePlayer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Write("Do you want to add another player ? (y/n) : ");
|
|
|
|
|
string? answer = ReadLine();
|
|
|
|
@ -38,14 +40,14 @@ static void AddPlayers(Game game)
|
|
|
|
|
static void ShowTiles(Game game)
|
|
|
|
|
{
|
|
|
|
|
WriteLine("\n --------------------- YOUR TILES ------------------------");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentPlayer = game.GetPlayingPlayer();
|
|
|
|
|
|
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentPlayer.Tiles.Count(); i++)
|
|
|
|
|
{
|
|
|
|
|
stringBuilder.Append("[" + (i+1) + "] ");
|
|
|
|
|
stringBuilder.Append("[" + (i + 1) + "] ");
|
|
|
|
|
stringBuilder.AppendLine(currentPlayer.Tiles[i].ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -65,12 +67,12 @@ static void AddTile(Game game)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tile = game.TileOfPlayerWithPos(no - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Write("Enter the x of the cell: ");
|
|
|
|
|
int x = Convert.ToInt32(ReadLine());
|
|
|
|
|
Write("Enter the y of the cell : ");
|
|
|
|
|
int y = Convert.ToInt32(ReadLine());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (game.PlaceTile(game.GetPlayingPlayer(), tile, x, y) == true)
|
|
|
|
|
{
|
|
|
|
|
WriteLine("ok ! your tile is placed");
|
|
|
|
@ -85,14 +87,14 @@ static void SwapTile(Game game)
|
|
|
|
|
{
|
|
|
|
|
var tilesToSwap = new List<Tile>();
|
|
|
|
|
bool continueSwap = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShowTiles(game);
|
|
|
|
|
|
|
|
|
|
while (continueSwap == true)
|
|
|
|
|
{
|
|
|
|
|
Write("Enter the number of the tile you want to swap : ");
|
|
|
|
|
int no = Convert.ToInt32(ReadLine());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (no is < 1 or > 6)
|
|
|
|
|
{
|
|
|
|
|
WriteLine("ERROR : Enter a number between 1 and 6 !");
|
|
|
|
@ -101,23 +103,23 @@ static void SwapTile(Game game)
|
|
|
|
|
{
|
|
|
|
|
tilesToSwap.Add(game.TileOfPlayerWithPos(no - 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Write("Do you want to swap another tile ? (y/n) : ");
|
|
|
|
|
string? answer = ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (answer == "n")
|
|
|
|
|
{
|
|
|
|
|
continueSwap = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
game.SwapTiles(game.GetPlayingPlayer(), tilesToSwap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MenuSwitch(Game game)
|
|
|
|
|
{
|
|
|
|
|
int enter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (enter != 3)
|
|
|
|
|
{
|
|
|
|
|
ShowTiles(game);
|
|
|
|
@ -152,11 +154,11 @@ static void MainMenu(Game game)
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
|
|
|
WriteLine("Game is starting !");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
string tagPlayerPlay = game.SetNextPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteLine(" --------------------- GAME ! ------------------------");
|
|
|
|
|
WriteLine(tagPlayerPlay + "'s turn !");
|
|
|
|
|
|
|
|
|
@ -169,16 +171,16 @@ static void MainMenu(Game game)
|
|
|
|
|
static void MainGame()
|
|
|
|
|
{
|
|
|
|
|
Game game = new Game();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
|
|
|
WriteLine(" ===================== WELCOME TO QWIRKLE ! =====================");
|
|
|
|
|
WriteLine("Enter the players' nametags (2 to 4 players) : ");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AddPlayers(game);
|
|
|
|
|
|
|
|
|
|
game.StartGame();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MainMenu(game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|