using QwirkleClassLibrary; using System.Net.Quic; using System.Text; using System.Transactions; using static System.Console; static void AddPlayers(Game game) { 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 !"); } Write("Do you want to add another player ? (y/n) : "); string? answer = ReadLine(); if (answer == "n" && game.PlayerList.Count >= 2) { break; } if (answer == "n" && game.PlayerList.Count < 2) { WriteLine("ERROR : You must have at least 2 players !"); } } } 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.AppendLine(currentPlayer.Tiles[i].ToString()); } Write(stringBuilder); } static void AddTile(Game game) { Tile? tile = null; Write("Enter the number of the tile you want to place : "); int no = Convert.ToInt32(ReadLine()); while (no is < 1 or > 6) { Write("ERROR : Enter a number between 1 and 6 ! : "); no = Convert.ToInt32(ReadLine()); } 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"); } else { WriteLine("ERROR : Cell already used"); } } static void SwapTile(Game game) { var tilesToSwap = new List(); 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 !"); } else { 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) { ShowBoard(game); ShowTiles(game); WriteLine("\n --------------------- CHOICES ------------------------"); WriteLine("[1] Place your tiles"); WriteLine("[2] Swap your tiles"); WriteLine("[3] Skip your turn"); enter = Convert.ToInt32(ReadLine()); switch (enter) { case 1: AddTile(game); break; case 2: SwapTile(game); enter = 3; break; case 3: return; } } } static void ShowBoard(Game game) { Board board = game.GetBoard(); List cells = board.GetCells(); for(int i=0; i