Пример #1
0
 //public static void WebGame(ConnectClient connectClient)
 //{
 //    int yourId, enemyId;
 //    VirtualArea first = connectClient.CreateArea(out yourId);
 //    RandomWebArea(first, connectClient, yourId);
 //    Console.WriteLine($"Your id {yourId}");
 //    Console.Write("Write enemy id:");
 //    enemyId = int.Parse(Console.ReadLine());
 //    VirtualArea second = new VirtualArea(connectClient.GetArea(enemyId, yourId));
 //    int progress = 0;
 //    bool gameisPlaying = true;
 //    while (gameisPlaying)
 //    {
 //        bool isPlayer = true;//connectClient.ImPlayer(enemyId);
 //        PrintGame(first, second);
 //        if (isPlayer)
 //        {
 //            char x; int y;
 //            progress++;
 //            Console.WriteLine($"Progress: {progress:D3}");
 //            Console.Write("x = ");
 //            x = Console.ReadKey().KeyChar;
 //            Console.Write("\ny = ");
 //            string temp;
 //            //if (!int.TryParse(Console.ReadLine(), out y) || connectClient.Fire(x - 'a', y - 1, enemyId, out temp) != 1)
 //            //{
 //            //    progress--;
 //            //    continue;
 //            //}
 //            //second.Update(temp);
 //        }
 //        else
 //        {
 //            int id;
 //            string wait;
 //            //while (connectClient.WaitData(out wait, out id))
 //            //{
 //            //    PrintGame(first, second);
 //            //    if (id == yourId)
 //            //    {
 //            //        first.Update(wait);
 //            //    }
 //            //    else
 //            //    {
 //            //        second.Update(wait);
 //            //    }
 //            //}
 //        }
 //    }
 //    PrintGame(first, second);
 //    Console.WriteLine($"Progress: {progress:D3}");
 //    Console.WriteLine("Кінець гри!");
 //    Console.ReadKey();
 //}
 static void PrintStartWebGame(VirtualArea area)
 {
     Console.Clear();
     Console.WriteLine("*РЕЖИМ ВСТАНОВЛЕННЯ КОРАБЛІВ*");
     Console.WriteLine("   A B C D E F G H I J");
     for (int i = 0; i < 10; i++)
     {
         Console.Write($"{i + 1:D2}|");
         Console.WriteLine(area.CreateLine(i).ToString() + '|');
     }
 }
Пример #2
0
 static void PrintGame(VirtualArea first, VirtualArea second)
 {
     Console.Clear();
     Console.WriteLine("*РЕЖИМ ГРИ*");
     Console.WriteLine("   A B C D E F G H I J       A B C D E F G H I J");
     for (int i = 0; i < 10; i++)
     {
         Console.WriteLine($"{i + 1:D2} " + first.CreateLine(i).ToString() + $" | {i + 1:D2} " + second.CreateLine(i).ToString() + '|');
     }
     //Console.WriteLine($"Dead ships {first.DeadShips:D2}                Dead ships {second.DeadShips:D2}");
 }