public async Task <bool> PostFigureBotAsync(string firstRequest, Commands commands) { PostRequest postRequest = new PostRequest(auth.client); var player = new Player() { Login = auth.AuthUser.Login, Password = auth.AuthUser.Password, Command = commands }; var response = await postRequest.ExecuteAsync <Player>(player, $"/{firstRequest}"); return(await PrintGameResultAsync(response)); }
public async Task <bool> AuthPostAsync(string request, User user) { PostRequest postRequest = new PostRequest(client); var response = await postRequest.ExecuteAsync <User>(user, request); if (response.StatusCode == HttpStatusCode.BadRequest) { CountOfBadLogin++; } else if (response.StatusCode == HttpStatusCode.OK) { CountOfBadLogin = 0; return(true); } return(false); }
public async Task <bool> PostFigureAsync(string firstRequest, string secondRequest, Commands commands, TimerClass timer) { PostRequest postRequest = new PostRequest(auth.client); var player = new Player() { Login = auth.AuthUser.Login, Password = auth.AuthUser.Password, Command = commands }; var responseForGame = await postRequest.ExecuteAsync <Player>(player, $"/{firstRequest}/{auth.Guid}"); if (commands == Commands.Exit) { await auth.client.GetAsync($"/{firstRequest}/{secondRequest}/{auth.Guid}"); return(false); } Console.Write("\nWaiting for the oponent\n"); while (true) { if (timer.inGoing == "Exit") { await auth.client.GetAsync($"/{firstRequest}/{secondRequest}/{auth.Guid}"); return(false); } var response = await auth.client.GetAsync($"/{firstRequest}/{secondRequest}/{auth.Guid}"); if (response.StatusCode == HttpStatusCode.OK) { var result = await response.Content.ReadAsStringAsync(); if (result.Equals("Draw")) { auth.Stat.Draws++; Console.WriteLine("Draw"); auth.Stat.Draws++; } else if (result.Equals(auth.AuthUser.Login)) { auth.Stat.Wins++; Console.WriteLine("You won!"); auth.Stat.Wins++; } else if (result.Equals("Exit")) { return(false); } else { auth.Stat.Loses++; Console.WriteLine("You loose :("); auth.Stat.Loses++; } Console.ReadKey(); timer.TimerDispose(); return(true); } else { //Console.WriteLine(response.StatusCode); //Console.Write("."); } } }