private void RefreshBoard(List <string> response) { BoardUI.DrawBoard(clientUsername, response[0]); BoardUI.ShowHP(GetHP(response)); BoardUI.ShowKills(GetKills(response)); BoardUI.ShowNearPlayers(GetNearPlayers(response)); Console.WriteLine("Action: "); }
private void JoinGame() { SocketConnection.SendMessage(BuildRequest(Command.JoinGame)); var response = new Response(SocketConnection.ReadMessage()); if (response.HadSuccess()) { BoardUI.DrawBoard(clientUsername, response.GetPlayerPosition()); Console.WriteLine("Action: "); if (timer == null) { timer = new Thread(() => TimesOut()); timer.Start(); } while (!exitGame && !timesOut) { string myAction = Input.RequestInput(); if (timesOut) { goto End; } if (myAction.Equals("exit")) { RemovePlayerFromGame(); exitGame = true; } else { SocketConnection.SendMessage(BuildRequest(Command.DoAction, myAction)); var sendActionResponse = new Response(SocketConnection.ReadMessage()); if (sendActionResponse.HadSuccess()) { List <string> actionResponse = sendActionResponse.GetDoActionResponse(); RefreshBoard(actionResponse); ShowIfGameFinished(actionResponse, false); } else if (sendActionResponse.IsInvalidAction()) { Console.WriteLine(sendActionResponse.ErrorMessage()); Console.WriteLine("Action: "); } else if (sendActionResponse.PlayerIsDead()) { Console.WriteLine(sendActionResponse.ErrorMessage()); string st = AskServerIfGameHasFinished(); if (st != "GameFinished") { Console.WriteLine("Please wait until game has finished. Type any key to continue..."); } else { goto End; } } else { Console.WriteLine(sendActionResponse.ErrorMessage()); RemovePlayerFromGame(); } } } ClientUI.Clear(); } else if (response.GameIsFull()) { Console.WriteLine(response.ErrorMessage()); } else { Console.WriteLine(response.ErrorMessage()); string aux = AskServerIfGameHasFinished(); } End :; }