using QwirkleClassLibrary; using System.Net.Quic; using System.Text; using System.Transactions; using static System.Console; static void addPlayer(Game game) { string? enterline = ""; do { WriteLine("Enter name of player (enter quit to quit) : "); enterline = ReadLine(); if (enterline != "quit") { bool r = game.AddPlayerInGame(enterline); if (r == false) { WriteLine("ERROR : Name is invalid."); } } } while (game.PlayerList.Count<4 && enterline !="quit"); } static void MainMenu(Game game) { game.TilsBagPlayer(); Console.ForegroundColor = ConsoleColor.Green; Write("The loading of the game is well done! Good game :p\n"); Console.ResetColor(); do { String TagPlayerPlay; TagPlayerPlay = game.NextPlayer(); Write(" --------------------- GAME ! ------------------------ \n"); Write(TagPlayerPlay + " you have main now ! \n"); MenuSwitch(game); } while (game.GetPlayingPlayerPosition() != 3); // cette boucle permet juste de faire un tour, quand le score fonctionnera il faudra la faire arreter quand la partie sera finis :) } static void ShowTiles(Game game) { Write("\n --------------------- YOUR TILES ------------------------ \n"); int pos = game.GetPlayingPlayerPosition(); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < game.PlayerList[pos].Tiles.Count(); i++) { stringBuilder.Append("[" + (i+1) + "] "); stringBuilder.AppendLine(game.PlayerList[pos].Tiles[i].ToString()); } Write(stringBuilder); } static void MenuSwitch(Game game) { int enter = 0; do { ShowTiles(game); Write("\n --------------------- CHOICES ------------------------ \n"); Write("[1] Place your tiles \n"); Write("[2] Swap your tiles \n"); Write("[3] Skip \n"); enter = Convert.ToInt32(ReadLine()); switch (enter) { case 1: CaseOneAddTile(game); break; case 2: break; case 3: return; } } while (enter != 3); } static void CaseOneAddTile(Game game) { Tile? tile = null; Write("Enter no tile : "); int no = Convert.ToInt32(ReadLine()); if (no >= 0 && no <= 5) { tile = game.TileOfPlayerWithPos(no+1); Write("Enter x : "); int x = Convert.ToInt32(ReadLine()); Write("Enter y : "); int y = Convert.ToInt32(ReadLine()); if (game.PlaceTileGame(tile, x, y) == true) { Write("ok ! your tile is placed \n"); } else { Write("ERROR : Cell already use \n"); } } else { Write("No is out of range\n"); } } static void MainGame() { Game game = new Game(); Console.BackgroundColor = ConsoleColor.DarkGreen; Write("WELCOME IN QWIRKLE GAME ! \n For start the game please enter 2 / 4 players ;) \n \n"); Console.ResetColor(); addPlayer(game); game.StartGame(); while (game.GameRunning == false) { game = new Game(); Console.ForegroundColor= ConsoleColor.Red; Write("ERROR : Please enter minimun 2 valid player ! \n"); Console.ResetColor(); addPlayer(game); game.StartGame(); } MainMenu(game); } MainGame();