public string Execute(string[] args, TcpClient client) { if (!CheckValid(args, client)) { return("multiPlayer"); } string direction = args[0]; // Get the game of the client who press play. GameMultiPlayer game = model.FindGameByClient(client); // Check the direction. if (!directions.Contains(direction)) { Controller.NestedErrors error = new Controller.NestedErrors("The dirction is incorrect", client); return("multiPlayer"); } // Check if the game exist. if (game != null) { NestedPlay nested = new NestedPlay(game.GetMaze().Name, direction); Controller.SendToClient(JsonConvert.SerializeObject(nested), game.OtherClient(client)); } else { // The game dosnt exits. Send message to the client. Controller.NestedErrors error = new Controller.NestedErrors("you need to start a game", client); } return("multiPlayer"); }
/// <summary> /// Executes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <param name="client">The client.</param> /// <returns></returns> public string Execute(string[] args, TcpClient client, string closeConnection, string keepOpen) { string direction = args[0]; Game game = model.FindGameByClient(client); if (game != null) { NestedPlay play = new NestedPlay(game.GetMaze().Name, direction, game.GetOpponent(client)); } else { new Controller.NestedError("you need to start a game first", client); } return(keepOpen); }
/// <summary> /// Execute the specified args and client. /// </summary> /// <returns>The execute.</returns> /// <param name="args">Arguments.</param> /// <param name="client">Client.</param> public string Execute(string[] args, TcpClient client) { string direction = args[0]; GameMultiPlayer game = model.FindGameByClient(client); if (!directions.Contains(direction)) { Controller.NestedErrors error = new Controller.NestedErrors("The dirction is incorrect}", client); return("multiPlayer"); } if (game != null) { NestedPlay nested = new NestedPlay(game.GetMaze().Name, direction); Controller.SendToClient(JsonConvert.SerializeObject(nested), game.OtherClient(client)); return("multiPlayer"); } else { Controller.SendToClient("{Erorr: you need to start a game}", client); return("singlePlayer"); } }