You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
using System;
|
|
using System.Net.Http;
|
|
using System.Threading;
|
|
|
|
namespace ConsoleApp1
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
using (var httpClient = new HttpClient())
|
|
{
|
|
Thread.Sleep(5000);
|
|
swaggerClient x = new swaggerClient("http://localhost:49746", httpClient);
|
|
while (true)
|
|
{
|
|
Field r = x.NewAsync().Result;
|
|
for (int ii = 0; ii < 5; ii++)
|
|
{
|
|
Thread.Sleep(500);
|
|
h_DrawField(r);
|
|
r = x.MoveAsync(r.Identifier).Result;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private static void h_DrawField(Field field)
|
|
{
|
|
Console.Clear();
|
|
|
|
h_WriteToConsole(field.Identifier, 4, 4, ConsoleColor.Gray);
|
|
|
|
|
|
foreach (var item in field.Figures)
|
|
{
|
|
ConsoleColor cc = item.FigureColor == 1 ? ConsoleColor.Blue : ConsoleColor.Green;
|
|
h_WriteToConsole("O", item.PosX, item.PosY, cc);
|
|
}
|
|
|
|
}
|
|
|
|
private static void h_WriteToConsole(string stringToWrite, int posX, int posY, ConsoleColor cc)
|
|
{
|
|
int realX = posX + 10;
|
|
int realY = posY + 10;
|
|
ConsoleColor oldCc = Console.ForegroundColor;
|
|
Console.ForegroundColor = cc;
|
|
Console.SetCursorPosition(realX, realY);
|
|
Console.Write(stringToWrite);
|
|
Console.ForegroundColor = oldCc;
|
|
}
|
|
}
|
|
}
|
|
|